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

ÏÂÃæÊÇÎÒËѼ¯µÄһЩ¾«ÃîµÄSQLÓï¾ä

ÏÂÃæÊÇÎÒËѼ¯µÄһЩ¾«ÃîµÄSQLÓï¾ä¡£
˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb)
SQL: select * into b from a where 1<>1
˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d,e,f from b;
˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
˵Ã÷£ºÍâÁ¬½Ó²éѯ(±íÃû1£ºa ±íÃû2£ºb)
SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
˵Ã÷£ºÈճ̰²ÅÅÌáÇ°Îå·ÖÖÓÌáÐÑ
SQL:  select * from Èճ̰²ÅÅ where datediff('minute',f¿ªÊ¼Ê±¼ä,getdate())>5
˵Ã÷£ºÁ½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾ­ÔÚ¸±±íÖÐûÓеÄÐÅÏ¢
SQL: 
delete from info where not exists ( select * from infobz where info.infid=infobz.infid )
˵Ã÷£ºËıíÁª²éÎÊÌ⣺
SQL: 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 .....
˵Ã÷£ºµÃµ½±íÖÐ×îСµÄδʹÓõÄIDºÅ
SQL:
SELECT (CASE WHEN EXISTS(SELECT * from Handle b WHERE b.HandleID = 1) THEN MIN(HandleID) + 1 ELSE 1 END) as HandleID
from  Handle
WHERE NOT HandleID IN (SELECT a.HandleID - 1 from Handle a)
 
COALESCE
·µ»ØÆä²ÎÊýÖеÚÒ»¸ö·Ç¿Õ±í´ïʽ¡£
Óï·¨
COALESCE ( expression [ ,...n ] )


Ïà¹ØÎĵµ£º

SQL Explorer QT4.5 ÅäÖÃMySQL ODBCºÍMySQLÇý¶¯

 QT DataBase SQL Explorer
1¡¢°²×°MySQLµ½¹Ù·½ÍøÕ¾ÏÂÔØMySQLÊý¾Ý¿â£¬·Ç°²×°°æ£¬Ö±½ÓÔËÐÐmysqld½ø³Ìǰ̨µÄ
2¡¢Ìí¼Óϵͳ»·¾³±äÁ¿£¬Path+=':\mysql\bin'µÄpath£¬ÔÙÔÚ¿ªÊ¼ÔËÐУ¬CMD->mysql -uroot µÇ¼µ½mySQLÊý¾Ý¿â
   Default passwordûÓеģ¬ÓеĻ° mysql -uroot -pÊäÈëÃÜÂ룻ÍøÂçµÇ¼£ºmysql -h ip ......

ʹÓÃTRY/CATCHÓï¾ä½â¾öSQL Server 2005ËÀËø

      ÈÃÎÒÃÇ´ÓÕâÑùÒ»¸öʾÀý¿ªÊ¼ËµÆð£¬ËüÔÚ SQL Server 2000 ºÍ 2005 Öж¼ÄÜÒýÆðËÀËø¡£ÔÚ±¾ÎÄÖУ¬ÎÒʹÓà SQL Server 2005 µÄ×îРCTP£¨ÉçÇø¼¼ÊõÔ¤ÀÀ£¬Community Technology Preview£©°æ±¾£¬SQL Server 2005 Beta 2£¨7 Ô·¢²¼£©Ò²Í¬ÑùÊÊÓá£Èç¹ûÄúûÓÐ Beta 2 »ò×îÐ嵀 CTP °æ±¾£¬ÇëÏÂÔØ SQL Serve ......

¸½¼Ósql server 20005Êý¾Ý¿â

·½·¨Ò»£º
1.Èç¹û¸½¼ÓÊý¾Ý¿âʱ£¬Ã»ÓÐÖ¸¶¨Âß¼­Ãû£¬ÔòÔÚSQL2005ÉÏÏÔʾΪ“ȫ·¾¶£¬ÇÒΪ´óд”¡£±ÈÈ磬Êý¾Ý¿âÎļþD:MyTest.mdfºÍD:MyTest.ldf£¬¸½¼Óµ½SQL·þÎñÆ÷ÉÏʱ£¬Èç¹ûûÓÐÖ¸¶¨Âß¼­Ãû£¬ÔòÔÚSQL2005ÉÏÏÔʾΪ“D:MYTEST.MDF”¡£´Ëʱ£¬C#µÄÁ¬½Ó×Ö·û´®Îª“DataSource=dsName;AttatchDBFilename=&rdquo ......

SQL ServerÖеÄCTE

 1¡¢¹«Óñí±í´ïʽ (CTE) ¿ÉÒÔÈÏΪÊÇÔÚµ¥¸ö SELECT¡¢INSERT¡¢UPDATE¡¢DELETE »ò CREATE VIEW Óï¾äµÄÖ´Ðз¶Î§ÄÚ¶¨ÒåµÄÁÙʱ½á¹û¼¯¡£CTE ÓëÅÉÉú±íÀàËÆ£¬¾ßÌå±íÏÖÔÚ²»´æ´¢Îª¶ÔÏ󣬲¢ÇÒÖ»ÔÚ²éѯÆÚ¼äÓÐЧ¡£ÓëÅÉÉú±íµÄ²»Í¬Ö®´¦ÔÚÓÚ£¬CTE ¿É×ÔÒýÓ㬻¹¿ÉÔÚͬһ²éѯÖÐÒýÓöà´Î¡£
¡¡¡¡CTE ¿ÉÓÃÓÚ£º
¡¡¡¡´´½¨µÝ¹é²éѯ¡£ÓйØÏêϸР......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ