SQl Cookbookѧϰ±Ê¼Ç
1.select * from A where a.a='a';
Ö´ÐÐ˳Ðò ÏÈÖ´ÐÐ from ÔÚÖ´ÐÐ where ÖеĶ«Î÷ £¬×îºóÖ´ÐÐ select
2.ÁÐÖµÁ¬½Ó db2 oracle || , mysql concat(column1,'sss',column2) sqlServlerʹÓÃ+Á¬½Ó;
3. case when ±í´ïʽ then ''
when ±í´ïʽ then ''
else ''
end
4. ÏÞÖÆ·µ»ØµÄÐÐÊý
ÔÚoracleÖÐʹÓÃrownum <= n ÏÞÖÆÐÐÊý
ÔÚdb2ÖÐʹÓÃfetch first 5 rows only
×¢Òâ oracleÖÐÈç¹ûʹÓÃrownum =5 Êǵò»µ½µÚÎåÐеģ¬ÒòΪoracleµÄ²éѯÔÀí»ñȡһÐк󸳸øÐкţ¬Èç¹ûÐкÅÂú×ãÌõ¼þ·µ»Ø·ñÔòÉáÆú£¬ÕâÑùÓÀÔ¶µÃ²»µ½µÚÎåÐУ¬ÓÀÔ¶ÊǵÚÒ»ÐкŲ¢½ÓÉáÆú£¬ËùÒÔÒªÏëµÃµ½µÚÎåÐУ¬±ØÐëµÃµ½Ç°ËÄÐУ¬ËùÒÔ²éѯǰÎåÐбØÐëÊÇ<= 5;
5.null ÒªÏëÅжÏÖµÊÇ·ñΪnull±ØÐëΪ is null £¬ null²»ÄÜÓõÈÓÚ=ºÍ²»µÈÓÚ<> ºÍÈκÎÖµ±È½Ï°üÀ¨null
6¡£°´Ä£Ê½²éѯ like '%a'
Ïà¹ØÎĵµ£º
±ÈÈçÏÖÔÚÓÐÒ»ÈËÔ±±í £¨±íÃû£ºpeosons£©
ÈôÏ뽫ÐÕÃû¡¢Éí·ÝÖ¤ºÅ¡¢×¡Ö·ÕâÈý¸ö×Ö¶ÎÍêÈ«ÏàͬµÄ¼Ç¼²éѯ³öÀ´
select p1.* from persons p1,persons p2 where p1.id<>p2.id and p1.cardid &nbs ......
Õý³£µÇ½sql*plusµÄ²½ÖèÈçÏ£º
sbdatabase*orcl-/home/oracle>sqlplus /nolog
SQL*Plus: Release 10.2.0.3.0 - Production on Sun May 9 19:50:24 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
SQL> conn hmsimis/test@orcl
Connected.
SQL>
¿ÉÒÔ¿´µ½Ç°ÃæµÄÌáʾ·ûÊÇSQL£¬ÏÖÔÚÏëÐ ......
²éѯËÙ¶ÈÂýµÄÔÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ£º
¡¡¡¡1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿)
¡¡¡¡7¡¢ ......
List<Class1> li = dc.Table_1.Where(item => item.id > 1).Cast<Class1>().ToList();
Table_1 Ϊ×Ô¶¯Éú³ÉÀà, class1Ϊ×Ô¶¨ÒåÀà,ÊôÐÔÃû³Æ¶¼ÊÇÒ»ÑùµÄ,ÒªÄÜʵÏÖÉÏÃæµÄÓï¾ä,±ØÐëÓм¸¸öÌõ¼þ
Table_1 ÐèÒª¼Ì³Ðclass1,¿ÉÒÔͨ¹ýpartialÀàÀ´ÊµÏÖ
Table_1 ÊôÐÔ¼Óoverride
class1ÀïÃæµÄÊôÐÔÒªÊÇvir ......