sql ÎÊÌâ
ÒÔÏÂÊÇsql
if(object_id('A') > 0)
drop table A
go
create table A(code int,date datetime)
insert into A
select 1,'2009-10-1'
union all select 1,'2009-10-05'
union all select 1,'2009-10-04'
union all select 1,'2009-10-02'
union all select 2,'2009-10-01'
union all select 2,'2009-10-02'
union all select 2,'2009-10-03'
union all select 3,'2009-10-05'
union all select 3,'2009-10-06'
if(object_id('test') > 0 )
drop table test
go
create table test (name varchar(100),value int)
insert into test
select 'xuhong',11
union all select 'xuhong',22
union all select 'chengguan',33
union all select 'chengguan',44
union all select 'daidai',114
ÏÂÃæ²éѯÓï¾ä²»ÄÜÀí½â
select * from A a where exists (select 1 from A where code = a.code having count(1) >= 3 ) --È«²¿½á¹û²é³öÀ´
select * from test a where exists(select 1 from test where a.name = name having count(1) >=2) --²é³ö²¿ÃŽá¹û
ÏÂÃæÁ½¸öÓï¾äºÍÉÏÃæÒ»ÑùµÄÇé¿ö
select * from test a where exists(select 1 from test where a.name = 'xuhong')
select * from A a where exists(sel
Ïà¹ØÎÊ´ð£º
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεϰ¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
»·¾³£º1.win2003server+oracle9i
2.oracle9i×Ö·û¼¯ÎªAMERICAN_AMERICA.WE8ISO8859P1
3.oracle sql developer°æ±¾ 1.5.5
ÏÖÏóÃèÊö: 1.ÔÚsql developer ÖвéѯoracleÖеÄij¸ö±í£¬ÖÐÎÄÈ«²¿ÏÔʾΪÂÒÂë¡£
......
ÇëÎÊһϣ¬ÍâÍøÁ½Ì¨SQLSERVERʵÀýÊý¾Ý´«Ê䣬ÓÐûÓвÉÓÃÊý¾ÝѹËõºÍ¼ÓÃÜ¡£Ñ¹Ëõ±ÈÊǶàÉÙ£¬¼ÓÃÜÊÇʲô¼ÓÃÜËã·¨£¿Ïà¹ØÎĵµÄÄÀï¿ÉÒÔÕÒµ½£¿Ð»Ð»
ÎÒÒ²ÏëÖªµÀ£¡¹Ø×¢´ËÌù£¡
¹Ø×¢¡«¡«
Êý¾Ý¿â´óÅ£¶¼ÄÄÈ¥Á˰¡£¿
......
ÔÚOracleÖУ¬ÎÒÏë²éϵͳʱ¼äÒ»ÌìµÄÊý¾Ý£¬Ê¹ÓÃÕâ¸öÓï¾ä
select * from tablename
where create_time>SYSDATE-1
and create_time <SYSDATE
ÎÒÏë²é×òÌì00£º00µ½½ñÌì00£º00µÄsqlÔõôд£¬
» ......