SQL²éѯÖظ´Êý¾ÝºÍÇå³ýÖظ´Êý¾Ý
ÓÐÀý±í£ºemp
emp_no name age
001 Tom 17
002 Sun 14
003 Tom 15
004 Tom 16
ÒªÇó£º
ÁгöËùÓÐÃû×ÖÖظ´µÄÈ˵ļǼ
(1)×îÖ±¹ÛµÄ˼·£ºÒªÖªµÀËùÓÐÃû×ÖÓÐÖظ´ÈË×ÊÁÏ£¬Ê×ÏȱØÐëÖªµÀÄĸöÃû×ÖÖظ´ÁË£º
select name from emp group by name having count(*)>1
ËùÓÐÃû×ÖÖظ´È˵ļǼÊÇ:
select * from emp
where name in (select name from emp group by name having count(*)>1)
(2)ÉÔ΢ÔÙ´ÏÃ÷Ò»µã£¬¾Í»áÏëµ½£¬Èç¹û¶Ôÿ¸öÃû×Ö¶¼ºÍÔ±í½øÐбȽϣ¬´óÓÚ2¸öÈËÃû×ÖÓëÕâÌõ¼Ç¼ÏàͬµÄ¾ÍÊǺϸñµÄ £¬¾ÍÓÐ
select * from emp where (select count(*) from emp e where e.name=emp.name) >1
--×¢ÒâÒ»ÏÂÕâ¸ö>1£¬ÏëÏÂÈç¹ûÊÇ =1£¬Èç¹ûÊÇ =2 Èç¹ûÊÇ>2 Èç¹û e ÊÇÁíÍâÒ»ÕÅ±í ¶øÇÒÊÇ=0Äǽá¹û ¾Í¸üºÃÍæÁË:)
Õâ¸ö¹ý³ÌÊÇ ÔÚÅжϹ¤ºÅΪ001µÄ ÈË µÄʱºòÏÈÈ¡µÃ 001µÄ Ãû×Ö£¨emp.name£© È»ºóºÍÔ±íµÄÃû×Ö½øÐÐ±È½Ï e.name
×¢ÒâeÊÇempµÄÒ»¸ö±ðÃû¡£
ÔÙÉÔ΢ÏëµÃ¶àÒ»µã£¬¾Í»áÏëµ½£¬Èç¹ûÓÐÁíÍâÒ»¸öÃû×ÖÏàͬµÄÈ˹¤ºÅ²»ÓëËýËûÏàͬÄÇôÕâÌõ¼Ç¼·ûºÏÒªÇó£º
select * from emp
where exists&
Ïà¹ØÎĵµ£º
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Ò»)--αÁÐROWNUMʹÓü¼ÇÉ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(¶þ)--±êÁ¿×Ó²éѯ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Èý)--PackageµÄÓŵã
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(ËÄ)--ÅúÁ¿´¦Àí
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Îå)--µ÷Óô洢¹ý³Ì·µ»Ø½á¹û¼¯
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Áù)- ......
12 Essential Steps After Installing SQL Server
By : Sadequl Hussain
Jul 13, 2009
from: http://www.sql-server-performance.com/articles/dba/post_installation_steps_p1.aspx
Rolling out SQL Servers is a key task for
DBAs. While for some DBAs this can be a frequent exercise, others wi ......
1¡¢Ñ»·²åÈë²âÊÔÊý¾Ý£º
SQL>
declare
maxrecords constant int:=100;
i int :=1;
Begin
for i in 1..maxrecords loop
--²åÈëÊý¾Ý
Insert into TEST.EXAMPLE(name,phone,address) values('·ÖÒ³²âÊÔÊý¾Ý....','ÁªÏµµç»°','ÁªÏµµØÖ·');
end loop;
commit;
end;
´Ë´¦EXAMPLE±í¶¨ÒåΪ(ID number,name ......
SQL SERVER 2008Öж¨Ê±±¸·ÝÊý¾Ý¿âÈÎÎñµÄ´´½¨Óëɾ³ý
[http://news.newhua.com/news1/program_database/2008/1215/0812151515485B22JHGBK9HJ87DK09D6958HB8K83EJ0053JKGC1A543.html]
ÓÉÓÚ֮ǰÊÇʹÓÃSQL SERVER 2000»òÕß2005£¬Õâ´Î¸ø¿Í»§°²×°Ê±Ê¹ÓÃ2008 SERVER£¬±¾ÒÔΪ´´½¨Êý¾Ý¿â¶¨Ê±±¸·ÝÈÎÎñ»áÓë2000/2005ÓкܴóÇø±ð£¬µ«¾ ......
1.²éѯµÄÄ£ºýÆ¥Åä
¾¡Á¿±ÜÃâÔÚÒ»¸ö¸´ÔÓ²éѯÀïÃæʹÓà LIKE '%parm1%'—— ºìÉ«±êʶλÖõİٷֺŻᵼÖÂÏà¹ØÁеÄË÷ÒýÎÞ·¨Ê¹Óã¬×îºÃ²»ÒªÓÃ.
½â¾ö°ì·¨:
ÆäʵֻÐèÒª¶Ô¸Ã½Å±¾ÂÔ×ö¸Ä½ø£¬²éѯËٶȱã»áÌá¸ß½ü°Ù±¶¡£¸Ä½ø·½·¨ÈçÏ£º
a¡¢ÐÞ¸Äǰ̨³ÌÐò——°Ñ²éѯÌõ¼þµÄ¹©Ó¦ÉÌÃû³ÆÒ»À¸ÓÉÔÀ´µÄÎı¾ÊäÈë¸ÄΪÏÂÀÁб ......