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

SQLÐÐתÁдúÂë

1. SQLÐÐתÁдúÂë
-
-
±íÀïÃæÓÐÕâôһ×éÊý¾Ý:
code                price
'MCU0-3'       15
'MCU0-3'       20
'MCU0-3'       22
'MCU3-15'     17
'MCU3-15'     16
'MCU3-15'     -10
'MCU3-15'     50
'MCU3-27'     99
'MCU3-27'     96
'MCU3-27'     54
'MCU3-27'     14
'MCU3-27'     46
'MCU3-27'     86
ÏÖÔÚÐèÒªµÃµ½ÕâÑùµÄ½á¹û:
MCU0-3   MCU3-15  MCU3-27
15              17               99
20              16               96
22              -10              54
null            50               14
null            null             46
null            null             86
SQLÓï¾äÊÇÕâÑùдµÄ:
 SELECT ID = IDENTITY(INT, 1, 1), price into #T1 from [table] where code = 'MCU0-3'
 SELECT ID = IDENTITY(INT, 1, 1), price into #T2  from [table] where code = 'MCU3-15'
 SELECT ID = IDENTITY(INT, 1, 1), price into #T3  from [table]


Ïà¹ØÎĵµ£º

[SQL]ÈçºÎд³ö¸ßЧµÄSQL

±ÜÃâʹÓÃIN ²Ù×÷·û
   ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ×¶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£
µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊDZȽϵ͵쬴ÓORACLEÖ´ÐеIJ½ÖèÀ´·ÖÎöÓÃINµÄSQLÓë²»ÓÃINµÄSQLÓÐÒÔÏÂÇø±ð£º
 ¡¡ORACLEÊÔͼ½«Æäת»»³É¶à¸ö±íµÄÁ¬½Ó£¬Èç¹ûת»»²»³É¹¦ÔòÏÈÖ´ÐÐINÀïÃæµÄ×Ó²éѯ£¬ÔÙ²éѯÍâ²ãµÄ±í¼Ç ......

SQLС¶Ì¾äÊÕ¼¯

Select TOP N * from TABLE Order By NewID() 
--Access£º
Select TOP N * from TABLE Order By Rnd(ID)  
Rnd(ID) ÆäÖеÄIDÊÇ×Ô¶¯±àºÅ×ֶΣ¬¿ÉÒÔÀûÓÃÆäËûÈκÎÊýÖµÀ´Íê³É£¬±ÈÈçÓÃÐÕÃû×Ö¶Î(UserName) 
Selec ......

SQLÓï¾äÖÐ N ºó½ÓÐø×Ö·û´®µÄ×÷ÓÃ

È磺SET @sql=N'SELECT * from stu'
ÆäÖГN”µÄ×÷ÓÃÊDZíʾºóÃæµÄ±àÂë¸ñʽΪunicode±àÂë
DECLARE @rst INT,@sql NVARCHAR(4000)
SET @sql=N'SELECT * from tb '
EXEC sp_executesql @sql,N'@rst INT OUTPUT',@rst OUTPUT
SELECT @rst
......

¹ØÓÚSQLʱ¼äÀàÐ͵ÄÄ£ºý²éѯ

½ñÌìÓÃtime Like '2008-06-01%'Óï¾äÀ´²éѯ¸ÃÌìµÄËùÓÐÊý¾Ý£¬±»ÌáʾÓï¾ä´íÎó¡£²éÁËһϲŷ¢ÏÖ¸ÃÄ£ºý²éѯֻÄÜÓÃÓÚStringÀàÐ͵Ä×ֶΡ£
×Ô¼ºÒ²²éÔÄÁËһЩ×ÊÁÏ¡£¹ØÓÚʱ¼äµÄÄ£ºý²éѯÓÐÒÔÏÂÈýÖÖ·½·¨£º
 
1.Convertת³ÉString,ÔÚÓÃLike²éѯ¡£
select * from table1   where c ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ