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

һЩ²»´íµÄsqlÓï¾ä

1¡¢ËµÃ÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb) (Access¿ÉÓÃ)
·¨Ò»£ºselect * into b from a where 1<>1
·¨¶þ£ºselect top 0 * into b from a
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 join c on a.a=c.c inner join d on a.a=d.d where .....
12¡¢ËµÃ÷£ºÈճ̰²ÅÅÌáǰÎå·ÖÖÓÌáÐÑ
SQL: select * from Èճ̰²ÅÅ where datediff('minute',f¿ªÊ¼Ê±¼ä,getdate())>5
13¡¢ËµÃ÷£ºÒ»Ìõsql Óï¾ä¸ã¶¨Êý¾Ý¿â·ÖÒ³
select top 10 b.* from (select top 20 Ö÷¼ü×Ö¶Î,ÅÅÐò×Ö¶Î from ±íÃû order by ÅÅÐò×Ö¶Î desc) a,±íÃû b where b.Ö÷¼ü×Ö¶Î = a.Ö÷¼ü×Ö¶Î order by a.ÅÅÐò×Ö¶Î
14¡¢ËµÃ÷£ºÇ°10Ìõ¼Ç¼
select top 10 * for


Ïà¹ØÎĵµ£º

SQLÖ®¾Å Êý¾Ý¿âÉè¼Æ

Íâ¼ü
======================
Íâ¼üÊÇÏà¶ÔÓÚÖ÷¼ü˵µÄ£¬Êǽ¨Á¢±íÖ®¼ä µÄÁªÏµµÄ±ØÐëµÄǰÌá¡£
   ±ÈÈ磺ѧÉú±í ¡¢Ñ§Éú³É¼¨±íÒ»Ò»¶ÔÓ¦ÊÇÒòΪ ËûÃǶ¼¾ßÓÐÏàͬµÄ×ֶΣºÑ§ºÅ£¬°ÑѧÉú±í×÷ΪÖ÷±í£¬Ñ§ºÅÊÇËûµÄÖ÷¼ü£¬Ïà¶ÔÓÚÖ÷±íÀ´Ëµ£¬Ñ§Éú³É¼¨µÄ×ֶΠѧºÅ¾ÍÊÇѧÉú±íµÄÍâ¼ü¡£
  ûÓÐÍâ¼ü£¬Á½¸ö±í¾Íû°ì·¨½¨Á¢ÁªÏµ°¡£¡ ......

AcessÓëSQLµÄÇø±ð

AcessÓëSQLµÄÇø±ð 
ÒÔÏÂ總結ÁË×Ô¼ºÔÚ項Ä¿ÖÐËùÓöµ½µÄÓÐ關Acess與SQL²î異µÄһЩµØ·½£º
1£¬¶ÔÓÚÈÕÆÚ×Ö¶Î×Ö¶Î
¡¡¡¡access±íʾΪ:#1981-28-12#
¡¡¡¡SQLSERVER2000±íʾΪ:''1981-02-12''
¡¡¡¡2,SQLÓï¾äÇø±ð£¬_select,_updateÔÚ¶Ôµ¥±í²Ù×÷ʱ¶¼²î²»¶à£¬
¡¡¡¡µ«¶à±í²Ù×÷ʱupdateÓï¾ ......

DBMS_SQL°üʵÏÖ¶¯Ì¬SQL

.ÔÚ²éѯÖлáÓöµ½ UNION ALL,ËüµÄÓ÷¨ºÍunionÒ»Ñù,Ö»²»¹ýunionº¬ÓÐdistinctµÄ¹¦ÄÜ,Ëü»á°ÑÁ½ÕűíÁËÖØ¸´µÄ¼Ç¼ȥµô,¶øunion all²»»á,ËùÒÔ´ÓЧÂÊÉÏ,union all »á¸ßÒ»µã.
2.union all Êǰ´Ô­ÏÈ˳ÐòÅÅÁеģ¬union °ÑÁ½ÕűíÖеÄÖØ¸´Êý¾ÝÈ¥µôºó»¹½øÐÐÁËÖØÐÂÅÅÐò
ÉùÃ÷£º´ËÎÄÀ´Ô´ÓÚÍøÂ·£¡
ÄÚÈÝÕªÒª£ºÔÚPL/SQL¿ª·¢¹ý³ÌÖУ¬Ê¹ÓÃSQL£¬ ......

sql¼òµ¥º¯ÊýÓ÷¨

¶¨Ò庯Êý
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER function [dbo].[FunJSLC](@carid bigint,@date datetime)
returns decimal
as
begin
declare @jslc decimal
set @jslc=(select JSLC from BYReMIn where iCarID=@carid and dtDate=@date)
return(@jslc)
end
´æ´¢¹ý³ÌÓ¦Óú¯Êý
set ANSI_NULLS ......

SQL Server 2000 ¸÷ÖÖ¶ÔÏóµÄ×î´óÖµ(ÊýÁ¿»ò´óС)

SQL Server 2000 ¸÷ÖÖ¶ÔÏóµÄ×î´óÖµ(ÊýÁ¿»ò´óС)
¹ÜÀíµÄÒ»¸öÊý¾Ý¿â´óС½«½ü10G£¬¿ªÊ¼µ£ÐÄÊý¾Ý¿â»á²»»á¹ý´ó£¬²éѯSQL ServerµÄÁª»ú´ÔÊéºó·¢ÏÖ×Ô¼ºµÄµ£ÐÄÕæµÄÊǶàÓàµÄ¡£
SQL Server 2000Êý¾Ý¿âÎļþ´óС£¨Êý¾Ý¡¢ÈÕÖ¾£©×î´ó¿ÉÒÔÖ§³Ö 32 TB µÄÎļþ
½ØÈ¡SQL Server 2000Áª»ú´ÔÊéÖеÄ×î´óÈÝÁ¿ËµÃ÷·½±ã´ó¼Ò²éÔÄ¡£
SQL ServerÊý¾Ý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ