sqlÓï¾äÎÊÌâ
ÓÐÒ»¸ö±íAA name tj 1 a 1 b 1 c 2 a 2 d 3 b ÒªÇóµ±tj×ֶεÄÖµ¼ÈµÈÓÚaÓÖµÈÓÚcʱ£¨tj = ¡®a¡¯ÓÖÒªtj = ¡®b¡¯£© Ò²¾ÍÊÇ˵ÎҵIJéѯÌõ¼þÊÇa¡¢c£¬ÎÒÒª²éµÄ½á¹ûÊÇ1
SQL code: select name from ( select distinct name from aa where tj ='a' union all select distinct name from aa where tj ='b' ) t group by name having count(1) = 2 SQL code: select * from AA where tj='a' and tj='c'ÒýÓà SQL codeselect*from AAwhere tj='a'and tj='c' Àí½â錯誤.´ó烏龜Õý½â.ÒýÓà SQL codeselect namefrom (selectdistinct namefrom aawhere tj='a'unionallselectdistinct namefrom aawhere tj='b' ) tgroupby namehavingcount(1)=2 up SQL code: create table aa(name int, tj varchar(10)) insert into aa values(1 , 'a') insert into aa values(1 , 'b') insert into aa values(1 , 'c') ins
Ïà¹ØÎÊ´ð£º
ÓÐÈý¸ö±íÒ»¸öÊDzɹºµ¥¸ñʽÈçÏ Èë¿âµ¥±í£º Èë¿âµ¥ºÅ ²úÆ· Öʼì±àºÅ Èë¿âÊýÁ¿ 001 Æ·ÖÖ1&n ......
¿Í»§±í£º ¿Í»§±àºÅ ¿Í»§ÏúÊÛ×ܶî aa 200 bb 300 cc ......
ÓÐʱºòÔÚÊý¾ÝÖвéѯÊý¾ÝµÄʱºò¿¼ÂÇÐÔÄÜÎÊÌ⣬»á½«¸´ÔÓÓï¾ä²ð·Ö»ò½èÓÃÁÙʱ±íÀ´¶à´Î²éѯ×îÖյõ½ÏëÒªµÄÊý¾Ý£¬ÏÖÔÚ½«ÕâЩ²éѯÄÚÈÝ×ö³É±¨±í£¬ÐèҪд¸öÓï¾äÒ»ÆøºÇ³É¡£ ÎÒÏëÎʵÄSQLÊÇ·ñ¿ÉÒÔÔÚ²éѯÓï¾äÒ»½áÊøºó£¬ÔÙ×Ô¶¯Ô ......
ÇóÔÚһͬһ¸ö±íÀïÃæ a b 10 7 (a-b)=a ÔÚÔÀ´µÄ±íA¶Î¸üÐÂΪ3 ÏÈлл¸÷λÁË,°ï¸öæ SQL code: update a set a=a-b SQL code: -->Title:Generating test data -->Author ......
create table [¿Í»§ÁªÏµ±í]([¿Í»§±àºÅ] varchar(2),[ÁªÏµÈÕÆÚ] datetime,[ÁªÏµÄÚÈÝ] int) insert [¿Í»§ÁªÏµ±í] select 'aa','2009/01/01',111 union all select 'bb','2009/02 ......