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

SQLÓï·¨ÓëÃüÁî


SQLÓï·¨ÓëÃüÁî
SELECT Óï¾ä
SELECT[predicate]{*|table.*|[table.]field [,[table.]field2[,...]]} [AS alias1
[,alias2[,...]]]
from tableexpression [,...][IN externaldatabase]
[WHERE...]
[GROUP BY...]
[HAVING...]
[ORDER BY...]
[WITH OWNERACCESS OPTION]
SELECT Óï¾ä°üÀ¨ÏÂÃ漸¸ö²¿·Ö
predicate
ÈçÇ°ÃæËùÊö£¬°üÀ¨ÁËALL£¬DISTINCT,DISTINCTROW,ÓëTOP
ÎÒÃÇ¿ÉÒÔÀûÓÃÕâÑùµÄÓï¾äÈ¥ÏÞÖƲéѯºóËùµÃµÄ½á¹û¡£
*
´ÓÖ¸¶¨±í¸ñÖÐÖ¸¶¨ËùÓеÄ×ֶΡ£
table
Õë¶Ô±»Ñ¡Ôñ³öµÄ¼Ç¼µÄ×ֶΣ¬ËùÖ¸¶¨±í¸ñµÄÃû³Æ¡£
field1,field2
ÏëÒª¶ÁÈ¡Êý¾ÝµÄ×Ö¶ÎÃû³Æ£¬Èç¹û°üº¬ÁËÒ»¸öÒÔÉϵÄ×ֶΣ¬»áÒÀÕÕÁгöµÄ˳ÐòÀ´¶ÁÈ¡Êý¾Ý¡£
alias1,alias2
ÓÃÀ´Ìæ´úÔÚ±í¸ñʵ¼Ê×Ö¶ÎÃû³ÆµÄ»¯Ãû¡£
tableexpression
±í¸ñÃû³Æ»ò°üº¬ÎÒÃÇËùÏëÒªµÄÊý¾ÝµÄ±í¸ñ¡£
externaldatabase
ÈôʹÓõ½²»ÊÇÄ¿Ç°µÄÊý¾Ý¿âÔò½«ÆäÃû×Ö¶¨ÒåÔÚexternaldatabaseµ±ÖС£
ALL,DISTINCT,DISTINCTROW,TOPÊôÐÔ´ÊÓ÷¨
SELECT [ALL|DISTINCT|DISTINCTROW|[TOP n[PERCENT]]] from table
ALL
ÈôÊÇÄú²»Ö¸¶¨ÈκεÄ×Ö¶ÎÊý¾Ý£¬ÔòMicrosoft JetÊý¾Ý¿âÒýÇ棨database
engine£©½«»áÑ¡ÔñËùÓеÄ×ֶΣ¬²¢ÒÀ¾ÝËù¶¨µÄÌõ¼þ²éѯ³öÐèÇóÊý¾Ý¼¯¡£
ÀýÈçÏÂÃæÕâÁ½¸öÀý×Ó½«»á¾ßÓÐÏàͬµÄЧ¹û£¬¶¼»á´ÓÖ°Ô±±í¸ñÖзµ»ØËùÓÐ×ֶεÄÊý¾Ý¡£
ÀýÈ磺
ÈôÊÇÎÒÃÇÒª²éѯ³öÖ°Ô±±í¸ñÖеÄËùÓмǼ£¬¿ÉÒÔͨ¹ýÏÂÃæµÄÓï¾äÀ´Íê³É¡£
SELECT ALL*
from Ö°Ô±±í¸ñ;
DISTINCT
¶Ôij¸ö±í¸ñËùÑ¡ÔñµÄ×Ö¶ÎÊý¾Ý£¬ÂÔ¹ýÖظ´µÄÇé¿ö£¬Ò²¾ÍÊÇ˵£¬Õë¶Ôij¸ö×ֶβéѯ³öÀ´µÄ¼Ç¼½á¹ûÊÇΨһµÄ¡£ÀýÈçÓÐÐí¶à´æ·ÅÔÚÖ°Ô±±í¸ñµÄÖ°Ô±
Êý¾Ý£¬Ò²Ðí»á¾ßÓÐÏàͬµÄÐÕÃû£¬ËùÒÔÈôÊÇÎÒÃÇÓÃSQLÓï¾äÖеÄSELECT
DISTINCT£¬Ôò²éѯ³öÀ´µÄ½á¹û½«»áÕë¶Ô²»Ò»ÑùµÄÐÕÃû¼ÓÒÔɸѡ¡£ÈôÊÇÄú°Ñ
DISTINCT ¼ÓÒÔÊ¡ÂÔ£¬ÔòÕâÑùµÄ²éѯ»áÏÔʾËùÓеļǼ¡£
DISTINCTROW
½«ÕûÌõ¼Ç¼Öظ´µÄ¼Ç¼ºöÂÔµô£¬¶ø²»ÊÇÖ»ÓÐÕë¶Ôijһ¸ö×ֶεÄÊý¾Ý¡£
table
Ö¸¶¨²éѯ¼Ç¼ËùÐèÒªµÄ±í¸ñ¡£
ÀýÈ磺
SELECT DISTINCTROW ¹«Ë¾Ãû³Æ
from ¹Ë¿Í±í¸ñ INNER JOIN ¶©µ¥±í¸ñ
ON ¹Ë¿Í±í¸ñ.¹Ë¿ÍID£½¶©µ¥±í¸ñ.¹Ë¿ÍID
ORDER BY ¹«Ë¾Ãû³Æ;
Èç¹ûÄúºöÂÔ DISTINCTROW
Ôò»á¶Ôÿ¸ö¹«Ë¾²úÉúÒ»ÐÐÒÔϵĶ©µ¥Êý¾Ý¡£´ËÍ⣬ÈôÊÇDISTINCTROWÖ»ÓÐÓÃÔÚÒ»¸ö±í¸ñµ±ÖУ¬Ôò»á±»Ê¡ÂÔµô¡£
TOP
´ÓµÚÒ»Ìõ»ò×îºóÒ»Ìõ¿ªÊ¼£¨ÀûÓÃORDER BYÌõ¼þ×Ӿ䣩£¬·µ»ØÌض¨ÌõÊýµÄÊý¾Ý¡£
ÀýÈ磺
µ±ÄúÏëÒªÖªµÀÔÚ2000Ä꣬°àÉÏÇ°25ÃûµÄѧÉúÐÕ


Ïà¹ØÎĵµ£º

ÓÃT SQLÓï¾äʵÏÖSQL serverÓëXLS,MDBµÈÎļþµÄÊý¾Ý½»»»

µÚÒ»²¿·Ö:SQL serverÓëACCESSÊý¾Ý¿âµÄ½»»»
Èí¼þ¿ª·¢Íø
1. ÔÚSQL SERVERÀï²éѯaccessÊý¾Ý: Èí¼þ¿ª·¢Íø
SELECT * from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source="c:\DB.mdb";User ID=Admin;Password=')...±íÃû
--------------------------------------------------------------------------
2. ½«ac ......

¸öÈË×ܽáµÄ¼¸Ìõ±È½ÏÓÐÒâ˼µÄsqlÓï¾ä


 
--------------------------------------------------------------------
-- ×÷ÕߣºÕÅ°®¹ú
-- ÈÕÆÚ£º2010-01-23 15:00:17
-- ÃèÊö: һЩ±È½ÏÓÐÒâ˼µÄSQLÓï¾ä
-- Version:
--    Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86)
--    Feb  9 2007 22:47:0 ......

´«ÖDz¥¿Íjavaѧϰ sql³£Óú¯Êý

ÎÒ½ñÌìѧϰÁËsqlÓï¾äµÄ³£Óú¯Êý£¬ÊÇ·ëÍþÀÏʦ½²µÄ£¬ÎÒ×öÁ˼òµ¥µÄ±Ê¼Ç£º
 
Ò»£¬SQLº¯Êý£º
1. ´óСдת»»º¯Êý
   lower ת³ÉСд  
   upper ´óд
   initcap  ½«×Ö·û´®µÄ(ÿ¸öµ¥´ÊµÄ)µÚÒ»¸ö×Öĸ±äΪ´óд,ºóÃæµÄСд
 select initcap('huangHY') from dual
&n ......

Linq Óësql·½Ê½ Ìí¼ÓÊý¾ÝЧÂʱȽÏ

Ëù²âÊÔ»·¾³Îª£ºMs sqlserver 2008£¬visual studio 2008
²âÊÔÊý¾ÝΪ10ÍòÌõ
 Linq·½Ê½ ´úÂ룺
/// <summary>
/// Linq ·½Ê½
/// </summary>
public static void Linq_insert()
{
DataClassesDataContext dataContext = new DataClassesDataContext();
......

SQL ServerÊý¾Ý¿âÊÂÎñÈÕÖ¾´æ´¢ÐòÁÐ

Èç¹ûÄãµÄÊý¾Ý¿âÔËÐÐÔÚÍêÕû»òÊÇÅúÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½Ï£¬ÄÇôÄã¾ÍÐèҪʹÓÃ×÷Òµ(job)À´¶¨ÆÚ±¸·ÝÊÂÎñÈÕÖ¾£¬±£³ÖÄãµÄÊÂÎñÎļþ´óС´¦ÔÚÒ»¸ö¿É¹ÜÀíµÄ·¶Î§¡£µ±ÄãÐèÒª»¹Ô­ÊÂÎñÈÕ־ʱ£¬Äã¾ÍÐèÒª°´ÕÕ´´½¨ÊÂÎñÈÕÖ¾µÄ˳ÐòÀ´»Ö¸´ËüÃÇ¡£Äã¿ÉÒԲο¼´æÔÚmsdb..backupset±íÖеÄÐÅÏ¢À´È·¶¨»¹Ô­ÎļþµÄ˳Ðò£¬Ê¹ÓÃFirstLSNºÍLastLSNÁеÄÖµ×÷²Î¿¼¡£µ±Ä ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ