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'
Ïà¹ØÎĵµ£º
¸ù¾ÝÉúÈÕµÄxxÔÂxxÈÕ²éÕÒÔÚ$checkDate¼ÆË㣬$beforeÈÕºóÉúÈյĿͻ§£º
$checkDateΪYYYY-MM-DD
WHERE substring(ADDDATE( '$checkDate', $before ),6,10)=substring(DATE_FORMAT(birthday,'%Y-%m-%d'),6,10)
$dates ÌìÄÚÉúÈյĿͻ§Î´¿¼Âǵ½Æ½Äê¡¢ÈòÄ꣺£º
$sql.=" (dayofyear( birthday )-dayofyear( ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......
ÓÃTSQL°ÑAccessµÄ±íµ¼Èëµ½Ô¶³ÌSql Server£º
°Ñaccess µÄ.mdbÀït_itemList ±íµÄÊý¾Ý²åÈëµ½Ô¶³ÌSqlServerµÄt_itemL1111111±íÀï¡£
SELECT top 10 * INTO t_itemL1111111 IN [ODBC]
[ODBC;Driver=SQL Server; UID=jyb;PWD=jyb;Server=10.1.18.49;DataBase=ËùÓкϲ¢;]
&nb ......
Ëø»úÖÆ
NOLOCKºÍREADPASTµÄÇø±ð¡£
1. ¿ªÆôÒ»¸öÊÂÎñÖ´ÐвåÈëÊý¾ÝµÄ²Ù×÷¡£
BEGIN TRAN t
INSERT INTO Customer
SELECT 'a','a'
2. Ö´ÐÐÒ»Ìõ²éѯÓï¾ä¡£
SELECT * from Customer WITH (NOLOCK)
½á¹ûÖÐÏÔʾ"a"ºÍ"a"¡£µ±1ÖÐÊÂÎñ»Ø¹öºó£¬ÄÇôa½«³ÉΪÔàÊý¾Ý¡£(×¢:1ÖеÄÊÂÎñδÌá½») ¡£NOLOCK±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......