³£Óà sqlÓï¾ä
SQL²åÈëÓï¾äµÃµ½×Ô¶¯Éú³ÉµÄµÝÔö ID Öµ
insert into Table1(Name,des,num) values ('ltp','thisisbest',10);
select @@identity as 'Id'
Ëæ»úÌáÈ¡Ìõ¼Ç¼µÄÀý×Ó
SQL Server£ºSelect Top 10 * from Tablename Order By NewID()
Access£ºSelect Top 10 * from Tablename Order By Rnd(ID)
Rnd(ID) ÆäÖеÄIDÊÇ×Ô¶¯±àºÅ×ֶΣ¬¿ÉÒÔÀûÓÃÆäËûÈκÎÊýÖµÀ´Íê³É£¬±ÈÈçÓÃÐÕÃû×Ö¶ÎUserName)
Select Top 10 * from ±íOrder BY Rnd(Len(UserName))
µÃ³öijÈÕÆÚËùÔÚÔ·ݵÄ×î´óÌìÊý
ELECT DAY(DATEADD(dd, -DAY('2008-02-13'),DATEADD(mm, 1, '2008-02-13')))
AS 'DayNumber'
°´ÐÕÊϱʻÅÅÐò
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
ͨÅä·ûµÄһЩÓ÷¨
1 select * from tablename where column1 like '[A-M]%'
ÕâÑù¿ÉÒÔÑ¡Ôñ³öcolumn×Ö¶ÎÖÐÊ××ÖĸÔÚA-MÖ®¼äµÄ¼Ç¼
2 select * from tablename where column1 like '[ABC]%'
ÕâÑù¿ÉÒÔÑ¡Ôñ³öcolumn×Ö¶ÎÖÐÊ××ÖĸÊÇA»òÕßB»òÕßCµÄ¼Ç¼
3 select * from tablename where column1 like '[A-CG]%'
ÕâÑù¿ÉÒÔÑ¡Ôñ³öcolumn×Ö¶ÎÖÐÊ××ÖĸÔÚA-CÖ®¼äµÄ»òÕßÊÇGµÄ¼Ç¼
4 select * from tablename where column1 like '[^C]%'
ÕâÑù¿ÉÒÔÑ¡Ôñ³öcolumn×Ö¶ÎÖÐÊ××Öĸ²»ÊÇCµÄ¼Ç¼
¸´ÖƱí½á¹¹£¨Ö»¸´Öƽṹ,Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb£©
select * into b from a where 1<>1
»ò
select top 0 * into [b] from [a]
Ïà¹ØÎĵµ£º
2.¸ù¾ÝOracle Êý¾Ý¿âscott ģʽϵÄemp ±íºÍdept ±í£¬Íê³ÉÏÂÁвÙ×÷£º
(1) ²éѯ20ºÅ²¿ÃŵÄËùÓÐÔ±¹¤ÐÅÏ¢£»
(2) ²éѯËùÓй¤ÖÖΪCLERK µÄÔ±¹¤µÄÔ±¹¤ºÅ¡¢Ô±¹¤ÃûºÍ²¿Ãźţ»
(3) ²éѯ½±½ðCOMM ¸ßÓÚ¹¤×ÊSAL µÄÔ±¹¤ÐÅÏ¢£»
  ......
¡¡×î½üΪÊý¾Ý¿â·þÎñÆ÷Ôö¼ÓÁËÄڴ棬´ïµ½ÁË×î´óÖ§³ÖµÄ8G£¬Êý¾Ý¿âÓõÄÊÇmssql 2005 £¬Ö®Ç°ÄÚ´æÒ»Ö±ÊÇ4GµÄ£¬²»´æÔÚÄÚ´æ´óºÍ32λ²Ù×÷ϵͳ³åÍ»µÄÊÂÇ飬32λ²Ù×÷ϵͳµ¥½ø³Ì×î´óÖ§³Ö2GµÄÄڴ棬ÕâÑù×ӵĻ°ÄÚ´æ¾Í°×¼ÓÁË£¬Ôõô°ìÄØ?
¡¡¡¡ÍøÉÏËÑË÷Á˺ܶà×ÊÁÏ£¬·¢ÏÖ΢ÈíÌṩÁËÒ»¸öËãÊÇÁÙʱµÄ½â¾ö·½°¸°É£¬Ê¹ÓÃAWEÀ´·ÖÅäÄڴ棬ÕâÑù×Ósqlse ......
ÎÊÌâÒ»¡¢Íü¼ÇÁ˵ǼMicrosoft SQL Server 2005 µÄsaµÄµÇ¼ÃÜÂë
½â¾ö·½·¨£ºÏÈÓÃwindowsÉí·ÝÑéÖ¤µÄ·½Ê½µÇ¼½øÈ¥£¬È»ºóÔÚ‘°²È«ÐÔ’-‘µÇ¼’-ÓÒ¼üµ¥»÷‘sa’-‘ÊôÐÔ’£¬ÐÞ¸ÄÃÜÂëµã»÷È·¶¨¾Í¿ÉÒÔÁË¡£
ÎÊÌâ¶þ¡¢Òѳɹ¦Óë·þÎñÆ÷½¨Á¢Á¬½Ó£¬µ«ÊÇÔڵǼ¹ý³ÌÖз¢Éú´íÈ¡¡££¨provider:¹ ......
SQLÖÐonÌõ¼þÓëwhereÌõ¼þµÄÇø±ð
Êý¾Ý¿âÔÚͨ¹ýÁ¬½ÓÁ½ÕÅ»ò¶àÕűíÀ´·µ»Ø¼Ç¼ʱ£¬¶¼»áÉú³ÉÒ»ÕÅÖмäµÄÁÙʱ±í£¬È»ºóÔÙ½«ÕâÕÅÁÙʱ±í·µ»Ø¸øÓû§¡£
ÔÚʹÓÃleft jionʱ£¬onºÍwhereÌõ¼þµÄÇø±ðÈçÏ£º
1¡¢ onÌõ¼þÊÇÔÚÉú³ÉÁÙʱ±íʱʹÓõÄÌõ¼ ......
SQL UNION ²Ù×÷·û
UNION ²Ù×÷·ûÓÃÓںϲ¢Á½¸ö»ò¶à¸ö SELECT Óï¾äµÄ½á¹û¼¯¡£
Çë×¢Ò⣬UNION ÄÚ²¿µÄ SELECT Óï¾ä±ØÐëÓµÓÐÏàͬÊýÁ¿µÄÁС£ÁÐÒ²±ØÐëÓµÓÐÏàËƵÄÊý¾ÝÀàÐÍ¡£Í¬Ê±£¬Ã¿Ìõ SELECT Óï¾äÖеÄÁеÄ˳Ðò±ØÐëÏàͬ¡£
SQL UNION Óï·¨
SELECT column_name(s) from table_name1
UNION
SELECT column_name(s) from tabl ......