×î½üϵͳÔËÐÐÖз¢ÏÖAccess 2003 °æ±¾ÖжԴý Null ºÍ ‘’ £¨¿Õ×Ö·û£©Ææ¹ÖÎÊÌ⣬ÖØÏÖ²½Ö裺
1¡¢´´½¨±ítabTest £»
2¡¢Ê¹ÓÃÉè¼ÆÊÓͼÌí¼ÓÁ½¸ö×ֶΠID £¬col1
Ãû³Æ
ÀàÐÍ
³¤¶È
˵Ã÷
ID
Number
Ö÷¼ü£¬×ÔÔö
Col1
char
1
ÎÞ
3¡¢Ê¹ÓÃsql Ìí¼ÓÈçÏÂÊý¾Ý
-- col1 ×Ö¶ÎÉèÖÃΪ null
INSERT INTO tabtest (id, col1) VALUES(1, NULL);
-- col1 ×Ö¶ÎÉèÖÃΪ ‘’
INSERT INTO tabtest (id, col1) VALUES(2, '');
-- col1 ×Ö¶ÎÉèÖÃΪ ‘a’
INSERT INTO tabtest (id, col1) VALUES(3, 'a');
4¡¢ÖØн¨Á¢²éѯÇëÇó£¬Í¨¹ý sql Ìí¼ÓÐÂ×ֶΠcol2
-- Ìí¼ÓÐÂÁÐcol2
ALTER TABLE tabTest ADD COLUMN col2 CHAR(1);
5¡¢Ê¹ÓÃÈçÏÂsql ÔÙ´ÎÏò tabTest Ìí¼ÓÐÂÊý¾Ý
-- col1£¬col2 ×Ö¶ÎÉèÖÃΪ null
INSERT INTO tabtest(id, col1, col2) VALUES(4, NULL, NULL);
-- col1£¬col2 ×Ö¶ÎÉèÖÃΪ ‘’
INSERT INTO tabtest(id, col1, col2) VALUES(5, '', '');
-- col1£¬col2 ×Ö¶ÎÉèÖÃΪ ‘a’
INSERT INTO tabtest(id, col1, col2) VALUES(6, 'a', 'a');
6¡¢´ò¿ª tabTest ¼ì²é Id Ϊ 5 µÄÊý¾Ý¡£ÉñÆæµÄÊÂÇé·¢ÉúÁË¡£
col1 ×Ö¶ÎΪ ³¤¶ÈΪ0 µÄ¿Õ×Ö·û´®£¬¶ø col2 Ϊ³¤¶ÈΪ1 µÄ×Ö·û
ÎÊÌ⣺
Q1¡¢ÎªºÎ ID Ϊ 2 µÄcol1 ×ֶΠºÍ col2 ×ֶζ¼Êdz¤¶ÈΪ 0 µÄ¿Õ×Ö·û£¬
¶ø ID Ϊ 5 µÄcol1 ×ֶΠºÍ col2 ×ֶγ¤¶È·Ö±ðΪ 0, 1 µÄ¿Õ×Ö·û£¬
ÔËÐÐÈçÏÂsql µÃµ½ÈçϽá¹û£º
SELECT id, len(col1) AS col1_³¤¶È, len(col2) AS col2_³¤¶È
from tabtest
WHERE id IN (2, 5);
Q2¡¢Í¨¹ýÈçÏÂsql È´Äܵõ½ID Ϊ5 µÄ¼Ç¼
SELECT *
from tabtest
WHERE col1 = ''
AND col2 = '';
±¾À´¿¼ÂÇÓÃXMLÎļþÀ´´æÊý¾ÝÊÇÒòΪÆä¿çƽ̨ÐÔ£¬¶øÇÒ²»Óð²×°Ìض¨µÄÈí¼þ¡£µ«¾¹ýÑо¿ÁËÒ»Õó×Ó·¢ÏÖ£¬XMLÓÃÓÚ´æ·ÅÉÙÊý¾ÝÊÇ¿ÉÒÔ£¬µ«´æ·Å´óÖÐÐÍÊý¾Ý¾ÍÏԵúܳÔÁ¦£¬»³ÒÉҲûÓÐÈË»áÕâô×ö¡£¶øÈç¹û²ÉÓÃSQL SERVER´æÊý¾Ý£¬ÓÖÏԵñȽÏÇü²Å£¬±Ï¾¹ÎÒ×öµÄÖ»ÊÇÑо¿¿Í»§¶ËµÄÒ»¸öС³ÌÐò£¬ÅäÖôú¼ÛҲ̫´óÁË¡£»ùÓÚÕâÁ½ÕßÖ®¼ä£¬»¹ÊǾö¶¨Ñ ......