(ת)SQL ²éÕÒÖظ´¼Ç¼
±ístuinfo£¬ÓÐÈý¸ö×Ö¶Îrecno(×ÔÔö),stuid,stuname
½¨¸Ã±íµÄSqlÓï¾äÈçÏ£º
CREATE TABLE [StuInfo] (
[recno] [int] IDENTITY (1, 1) NOT NULL ,
[stuid] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[stuname] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
1.--²éijһÁÐ(»ò¶àÁÐ)µÄÖظ´Öµ(Ö»Äܲé³öÖظ´¼Ç¼µÄÖµ£¬²»ÄÜÕû¸ö¼Ç¼µÄÐÅÏ¢)
--Èç:²éÕÒstuid,stunameÖظ´µÄ¼Ç¼
select stuid,stuname from stuinfo
group by stuid,stuname
having(count(*))>1
2.--²éijһÁÐÓÐÖظ´ÖµµÄ¼Ç¼(ÕâÖÖ·½·¨²é³öµÄÊÇËùÓÐÖظ´µÄ¼Ç¼,Ò²¾ÍÊÇ˵Èç¹ûÓÐÁ½Ìõ¼Ç¼Öظ´µÄ£¬¾Í²é³öÁ½Ìõ)
--Èç:²éÕÒstuidÖظ´µÄ¼Ç¼
select * from stuinfo
where stuid in (
select stuid from stuinfo
group by stuid
having(count(*))>1
)
3.--²éijһÁÐÓÐÖظ´ÖµµÄ¼Ç¼(Ö»ÏÔʾ¶àÓàµÄ¼Ç¼,Ò²¾ÍÊÇ˵Èç¹ûÓÐÈýÌõ¼Ç¼Öظ´µÄ£¬¾ÍÏÔʾÁ½Ìõ)
--ÕâÖÖ·½³É¼¨µÄÇ°ÌáÊÇ£ºÐèÓÐÒ»¸ö²»Öظ´µÄÁÐ,±¾ÀýÖеÄÊÇrecno
--Èç:²éÕÒstuidÖظ´µÄ¼Ç¼
select * from stuinfo s1
where recno not in (
select max(recno) from stuinfo s2
where s1.stuid=s2.stuid
)
ÏÂÃæÕâ¸öÊDzé³öËùÓÐÖظ´¼Ç¼µÄSQLÓï¾ä£º
·½·¨1£º
SQL> Select * from table_name A WHERE ROWID > (
SELECT min(rowid) from table_name B
WHERE A.key_values = B.key_values);
·½·¨2£º
SQL> select * from table_name t1
where exists (select 'x' from table_name&n
Ïà¹ØÎĵµ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Dat ......
ËäȻֱ½Ó½«ÎļþÄÚÈÝ´æÈëÊý¾Ý¿â×ֶεÄÇé¿ö²»¶à£¬²»¹ýÔÚ¶ÔÓÚÎļþÄÚÈݻᷢÉú±ä»¯µÄÇé¿öÏ´æÈëÊý¾Ý¿â×Ö¶ÎÒ²²»Ê§ÎªÒ»ÖÖ·½·¨¡£
Æäʵ·½·¨ºÜ¼òµ¥£¬ÕâÀïÓõ½Ò»¸öload_fileº¯Êý£¬²»ÖªµÀÊDz»ÊÇÎÒϵÄMYSQLÊÖ²áÓÐÎÊÌâ¡£ÎÒÔÚÕÒÕâ¸öº¯ÊýµÄʱºòË÷ÒýºÍÄÚÈݲ»¶ÔÓ¦¡£
Ê×ÏÈÊǽ¨±íÓï¾ä
create table test (id int,file blob);
²åÈëÓï¾ ......
¾³£½øÐвéѯ£¬Ð´×Åselect * from Ì«·Ñʱ¼ä£¬Äܲ»ÄÜÖ±½ÓÊäÈëÒ»¸ös ¾ÍÄÜ×Ô¶¯³öÀ´ select * from Âð£¿
·¢ÏÖpl/sqlÖпÉÒÔÅäÖÃ×Ô¶¯Ìæ»»
ÔÚPL/SQLµÄ°²×°Ä¿Â¼ÏÂÃ棺$\PLSQL Developer\PlugIns ÖÐÌí¼ÓÒ»¸öÎı¾Îļþ£¬±ÈÈçÃüÃûΪ:AutoReplace.txt¡£Îı¾ÎļþÖÐÌîдÈçÏÂÄÚÈÝ£º
st = select t.* ,t.rowid from t
s = se ......
ÓÃselectÓï¾ä£¬²éѯÖظ´¼Ç¼
¼ÙÉ裬±íÃûΪ T1 ×Ó¶ÎΪ A,B,C
select count(*) ,A,B,C from T1
group by A,B,C having count(*) > 1
²âÊÔÊý¾Ý£º
A100 B100 C100&nbs ......