sqlÊý¾Ý¹ýÂË
Ò». ²éÕÒÖظ´¼Ç¼
1. ²éÕÒÈ«²¿Öظ´¼Ç¼
Select * from ±í Where Öظ´×ֶΠIn (Select Öظ´×Ö¶Î
from ±í Group By Öظ´×ֶΠHaving Count(*)>1)
2. ¹ýÂËÖظ´¼Ç¼(Ö»ÏÔʾһÌõ)
Select * from HZT Where ID In (Select Max(ID) from HZT Group By Title)
×¢£º´Ë´¦ÏÔʾID×î´óÒ»Ìõ¼Ç¼
¶þ. ɾ³ýÖظ´¼Ç¼
1. ɾ³ýÈ«²¿Öظ´¼Ç¼£¨É÷Óã©
Delete ±í Where Öظ´×ֶΠIn (Select Öظ´×ֶΠfrom ±í
Group By Öظ´×ֶΠHaving Count(*)>1)
2. ±£ÁôÒ»Ìõ
Delete HZT Where ID
Not In (Select Max(ID) from HZT Group By Title)
Èý. ¹ýÂËselect²éѯµÃµ½µÄÖظ´Êý¾Ý
1.
¹ýÂËÒ»´Îselect²éѯÖеÄÖظ´Êý¾Ý£º
select distinct HZD from t_Table where MZD in (...)
distinct
2.
¹ýÂËÁ½´Îselect²éѯÖеÄÖظ´Êý¾Ý£º
select¡£¡£¡£where ¡£¡£(select ¡£¡£¡£¡£¡£¡£union select¡£¡£¡£¡£)
½éÉܼ¸¸öSQLÖ¸Á
UNION
£¬ÓÃÓÚ»ñÈ¡Á½¸ö½á¹û¼¯µÄ²¢¼¯£¬»á×Ô¶¯È¥µô½á¹û¼¯ÖеÄÖظ´ÐУ¬²¢»áÒÔµÚÒ»ÁеĽá¹û½øÐÐÅÅÐò
INTERSECT
£¬ÓÃÓÚ»ñÈ¡Á½¸ö½á¹û¼¯µÄ½»¼¯£¬²¢ÇÒÒÔµÚÒ»ÁÐÅÅÐò
MINUS
£¬ÓÃÓÚ»ñÈ¡½á¹û¼¯µÄ²î¼¯£¨»òÕß˵²¹¼¯£©£¬ÏÔʾµÚÒ»¸ö½á¹û¼¯´æÔڵģ¬µÚ2¸ö½á¹û¼¯²»´æÔÚµÄÊý¾Ý
UNION ALL
£¬ÓëUNIONÏàËÆ£¬²»Í¬µÄÊÇUNION
ALL²»»á×Ô¶¯È¥´¦Öظ´ÐУ¬Ò²²»»áÒÔÈκÎÁÐÅÅÐò
Ltrim£¬Rtrim
£¬È¥³ý×óÓҵIJ»Í¬×Ö·û´®
ÒÔÉϸöÖ¸ÁîµÄ¾ßÌåÓ÷¨È¥²é×ÊÁÏ£¬ÔÚ´Ë×ö¸ö±¸Íü
posted @ 2009-06-18
09:25
ʧÒäµÄÓ²ÅÌ ÔĶÁ(30) | ÆÀÂÛ
(0)
|
2009Äê2ÔÂ20ÈÕ
´Ó·þÎñÆ÷ÉÏ´«ºÍÏÂÔØ
==============================================
ÉÏ´«
==============================================
GetDb_IT myGetDb_IT = new GetDb_IT();
SqlDataReader dr;
string mysql = "";
string
DB_Path="";
string path = "";
&nb
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
ΪÁËÑо¿Ò»ÏÂϵͳÔÚºǫ́¶¼¸ÉÁËʲô£¬µ±È»ÊÇÎÒÔÚ´úÂëÀïûÕÒµ½µÄÇé¿öÏ£¬Ñо¿ÁËÒ»ÏÂtrace£¬½á¹ûÓÐÒ»¶¨µÄ°ïÖú¡£oracleÖв»Ïñsql serverÖÐÄÇÑùÖ±½ÓÌṩͼÏñ»¯µÄ¹¤¾ß£¬ËùÒÔ»¹ÊǵÃ×Ô¼º¶¯ÊÖÀ´×ö£¬¹éÄÉÁËһϣ¬²½ÖèÈçÏ£º
²éѯsession£º
SQL> select sid, serial#, username from v$session where username='XXX';//ÕÒ³öÄãÒª¸ú ......
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄÇ ......
ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØϵÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌص㣬ҲÊÇËüÇø±ðÓÚÆäËüÀàÐÍ
Êý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØϵÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹Øϵ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚ
Ò»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû ......