sqlÖÐ||ÊÇʲôÒâ˼
sqlÖÐµÄ || ·ûºÅ´ú±í×Ö·û¹´Í¨½ÓÔËËã·û£¬Ëü½«Á½¸ö×Ö·û¹´Í¨½Ó³ÉÒ»¸öеÄ×Ö·û´®¡£Ê¹ÓÃÈçÏÂÓï·¨£ºexpression1 || expression2£»ÆäÖУ¬expression1 ºÍ expression2 ÊÇ×Ö·û´®±í´ïʽ¡£ÈôÊÇÆäÖÐÒ»¸ö±í´ïʽΪ null£¬Ð§¹û½«Îª·Ç null ±í´ïʽ¡£|| ÔËËã·ûÓÅÏȼ¶µÍÓÚ×Ö·û´®½ÏÁ¿ÔËËã·û£¬ÔÚÅþÁ¬Êý×Öʱ»á½«ËüÃÇת»»Îª×Ö·û´®¡£
SQL ÖÐ || µÄ¼ÄÒå
ÔÚ SQL ÅÌÎÊÖУ¬|| ·ûºÅÌåÏÖ×Ö·û¹´Í¨½ÓÔËËã·û¡£Ëü½«Á½¸ö×Ö·û¹´Í¨½Ó³ÉÒ»¸öеÄ×Ö·û´®¡£
Óï·¨£º
expression1 || expression2
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬expression1 ºÍ expression2 ÊÇ°üÀ¨×Ö·û´®ÖµµÄ±í´ïʽ¡£
ÐÐΪ£º
ÈôÊÇÁ½¸ö±í´ïʽ¶¼ÊÇ×Ö·û´®£¬ÔòÔËËã·û½«ËüÃÇÅþÁ¬ÔÚÒ»Æð¡£
ÈôÊÇÆäÖÐÒ»¸ö±í´ïʽÊÇ NULL£¬ÔòЧ¹ûΪÁíÒ»¸ö±í´ïʽ¡£
ʾÀý£º
SELECT 'John' || ' Doe'; -- Ч¹û£º'John Doe' SELECT NULL || ' Doe'; -- Ч¹û£º' Doe'
µÇ¼ºó¸´ÖÆ
Ó¦Óó¡¾°£º
|| ÔËËã·ûͨ³£ÓÃÓÚÒÔϳ¡¾°£º
ÅþÁ¬¶àÁÐÖеÄÖµÒÔ½¨ÉèеÄ×Ö·û´®¡£
½«Ç°×º»òºó׺Ìí¼Óµ½ÏÖÓÐ×Ö·û´®¡£
ÔÚ×Ö·û´®ÖвåÈë¿Õȱ»òÆäËû×Ö·û¡£
ÆäËû×¢ÖØÊÂÏ
|| ÔËËã·ûµÄÓÅÏȼ¶µÍÓÚ×Ö·û´®½ÏÁ¿ÔËËã·û¡£
ÔÚÅþÁ¬Êý×Öʱ£¬|| ÔËËã·û»á½«ËüÃÇת»»Îª×Ö·û´®¡£
ÒÔÉϾÍÊÇsqlÖÐ||ÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡