×ðÁú¿­Ê±¹ÙÍøµÇ¼

sqlÖÐisnullµÄÓ÷¨

sql ÖÐ isnull º¯Êý¼ì²éÖµÊÇ·ñΪ null  £¬²¢·µ»ØÖ¸¶¨Öµ£¨ÈôÊÇֵΪ null£©»òԭʼֵ£¨ÈôÊÇֵΪ·Ç null£©¡£ËüµÄÓ﷨Ϊ£ºisnull(expression, replacement_value)¡£¸Ãº¯ÊýÓÃÓÚÌæ»» null ÖµÒÔÌá¸ß¿É¶ÁÐÔ¡¢±ÜÃâ¹ýʧºÍÔھۺϺ¯ÊýÖд¦Àí null Öµ¡£

SQL ÖÐ ISNULL º¯ÊýµÄÓ÷¨

ʲôÊÇ ISNULL º¯Êý £¿

ISNULL º¯ÊýÊÇÒ»ÖÖ SQL º¯Êý  £¬ÓÃÓÚ¼ì²éÖµÊÇ·ñΪ NULL  £¬²¢·µ»ØÒ»¸öÖ¸¶¨Öµ£¨ÈôÊÇֵΪ NULL£©»òԭʼֵ£¨ÈôÊÇֵΪ·Ç NULL£©¡£

Óï·¨£º

ISNULL(expression, replacement_value)

ÆäÖУº

expression£ºÒª¼ì²éµÄÖµ¡£

replacement_value£ºÈôÊÇ expression Ϊ NULL  £¬Ôò·µ»ØµÄÖµ¡£

Ó÷¨£º

ISNULL º¯Êý¿ÉÓÃÓÚÖÖÖÖÇéÐÎ  £¬ÀýÈ磺

Ìæ»» NULL ֵΪ¸üÓѺõÄÖµ  £¬ÒÔÌá¸ßÊý¾Ý¿É¶ÁÐÔ¡£

±ÜÃâ¿ÕÖµµ¼Ö¹ýʧ»òÒâÍâЧ¹û¡£

ÔھۺϺ¯Êý£¨Èç SUM¡¢COUNT£©Öд¦Àí NULL Öµ¡£

ʾÀý£º

˼Á¿ÒÔϱí¸ñ£º

ID Name
1 John Smith
2 NULL

ÒªÌæ»» Name ÁÐÖÐΪ NULL µÄÖµ  £¬¿ÉÒÔʹÓÃÒÔÏÂÅÌÎÊ£º

SELECT ID, ISNULL(Name, 'Unknown') FROM TableName;

µÇ¼ºó¸´ÖÆ

Êä³ö£º

ID Name
1 John Smith
2 Unknown

×¢ÖØÊÂÏ

ISNULL º¯ÊýµÄµÚÒ»¸ö²ÎÊý±ØÐèÊDZí´ïʽ  £¬²»¿ÉÊÇ×ÓÅÌÎÊ¡£

ÈôÊÇ replacement_value Ϊ NULL  £¬ISNULL º¯Êý½«·µ»Ø expression ×Ô¼º  £¬¶ø²»»á¾ÙÐÐÌæ»»¡£

ISNULL º¯ÊýÓë COALESCE º¯ÊýÀàËÆ  £¬µ« COALESCE º¯Êý¿ÉÒÔ½ÓÊܶà¸ö replacement_value¡£

ÒÔÉϾÍÊÇsqlÖÐisnullµÄÓ÷¨µÄÏêϸÄÚÈÝ  £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí  £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø  £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È  £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ  £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢  £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢  £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå  £¬9:30-18:30  £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ