Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sqlÓï¾ä

¾­µäSQLÓï¾ä
1¡¢ËµÃ÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb) (Access¿ÉÓÃ)
   ·¨Ò»£ºselect * into b from a where 1<>1
   //a±ØÐëÊÇÒѾ­´æÔÚµÄ±í£¬µ«ÊÇb¿ÉÒÔ²»´æÔÚ£¬µ±b²»´æÔÚʱ£¬ÏµÍ³»á×Ô¼º´´½¨±íb,¸Ã·½·¨Ö»»á¸´ÖƱíµÄ½á¹¹£¬¶ø²»»á¸´ÖƱíµÄÊý¾Ý
   ·¨¶þ£ºselect top 0 * into b from a
   //a±ØÐëÊÇÒѾ­´æÔÚµÄ±í£¬µ«ÊÇb¿ÉÒÔ²»´æÔÚ£¬µ±b²»´æÔÚʱ£¬ÏµÍ³»á×Ô¼º´´½¨±íb,ϵͳ»á½«a±íµÄ½á¹¹ºÍÈ«²¿Êý¾Ý¶¼¸´ÖƵ½±íbÖÐ
2¡¢ËµÃ÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb) (Access¿ÉÓÃ)
   insert into b(a, b, c) select d,e,f from b;
3¡¢ËµÃ÷£º¿çÊý¾Ý¿âÖ®¼ä±íµÄ¿½±´(¾ßÌåÊý¾ÝʹÓþø¶Ô·¾¶) (Access¿ÉÓÃ)
   insert into b(a, b, c) select d,e,f from b in ‘¾ßÌåÊý¾Ý¿â’ where Ìõ¼þ
Àý×Ó£º..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..
4¡¢ËµÃ÷£º×Ó²éѯ(±íÃû1£ºa ±íÃû2£ºb)
   select a,b,c from a where a in (select d from b )
   »òÕß: select a,b,c from a where a in (1,2,3)
5¡¢ËµÃ÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
   select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
6¡¢ËµÃ÷£ºÍâÁ¬½Ó²éѯ(±íÃû1£ºa ±íÃû2£ºb)
   select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
7¡¢ËµÃ÷£ºÔÚÏßÊÓͼ²éѯ(±íÃû1£ºa )
   select * from (SELECT a,b,c from a) T where t.a > 1;
8¡¢ËµÃ÷£ºbetweenµÄÓ÷¨,betweenÏÞÖƲéѯÊý¾Ý·¶Î§Ê±°üÀ¨Á˱߽çÖµ,not between²»°üÀ¨
   select * from table1 where time between time1 and time2
   select a,b,c, from table1 where a not between ÊýÖµ1 and ÊýÖµ2
9¡¢ËµÃ÷£ºin µÄʹÓ÷½·¨
   select * from table1 where a [not] in (‘Öµ1’,’Öµ2’,’Öµ4’,’Öµ6’)
10¡¢ËµÃ÷£ºÁ½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾ­ÔÚ¸±±íÖÐûÓеÄÐÅÏ¢
   delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )
11¡¢ËµÃ÷£ºËıíÁª²éÎÊÌ⣺
   select * from a left inner join b on a.a=b.b right inner joi


Ïà¹ØÎĵµ£º

sqlÊý¾Ý¿â±¸·Ý

sql serverÊý¾Ý¿â±¸·Ý·½°¸
2008-08-05 13:15
SQL Server Êý¾Ý¿â±¸·Ý·½°¸
ΪÁ˱£Ö¤SQL Server Êý¾ÝµÄ°²È«£¬Êý¾Ý¿â¹ÜÀíÔ±Ó¦¶¨ÆÚ±¸·ÝÊý¾Ý¿â£¬ÔÚ²»Í¬Çé¿öÏÂÓ¦²ÉÓò»Í¬±¸·ÝÊý¾Ý¿â±¸·Ý²ßÂÔ£¬Ò»·½Ãæά³ÖÊý¾ÝµÄ°²È«ÐÔ£¬ÁíÒ»·½ÃæÒ²¿É±£³ÖSQL Server ÄÜ˳³©ÔËÐС£¾¡×î´óµÄŬÁ¦¼õÉÙÓÉÓÚÊý¾ÝµÄË𻵶Կͻ§Ôì³ÉµÄËðʧ¡£
¸ÅÄî
1) ±¸·Ý ......

ÔÚSQL ServerÖÐÈçºÎÊä³öÐкÅ


Ô­ÎĵØÖ·£ºhttp://www.dingos.cn/index.php?topic=1688.0
OracleÓÐrownumÓÃÓÚ·ÃÎʱíÖÐÐкš£ÄÇôÔÚSQL ServerÖÐÊÇ·ñÓеÈЧµÄÄØ£¿»òÕßÔÚSQL ServerÖÐÈçºÎÊä³öÐкţ¿
-----------------------------------
ÔÚSQL ServerÖÐûÓÐÖ±½ÓµÈЧÓÚOracleµÄrownum
-----------------------------------
Ñϸñ˵À´£¬ÔÚ¹ØϵÊý¾Ý¿âÖУ ......

SQL »ñÈ¡ÁÐÃû ÀûÓÃϵͳ±í

SELECT sysobjects.name,syscolumns.name
from  sysobjects,syscolumns
WHERE(sysobjects.id=syscolumns.id)
select col_name(OBJECT_ID(£§staff£§),17)
select name
from syscolumns
where id=object_id(£§ÄãµÄ±íÃû£§); ......

¡¾×ª¡¿ ORACLE³£ÓÃSQLÓÅ»¯hintÓï¾ä

ORACLE³£ÓÃSQLÓÅ»¯hintÓï¾ä
http://oracle.chinaitlab.com/induction/802186.html
ÔÚSQLÓï¾äÓÅ»¯¹ý³ÌÖУ¬ÎÒÃǾ­³£»áÓõ½hint,ÏÖ×ܽáÒ»ÏÂÔÚSQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨£º
¡¡¡¡1. /*+ALL_ROWS*/
¡¡¡¡±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
¡¡¡¡ÀýÈç:
¡¡¡¡SELECT /*+ALL+_ROW ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ