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

Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé

from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£
 
¡¡¡¡Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé:
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01','yyyy-mm-dd');
¡¡¡¡¡ôÔÚ¹ýÂËÌõ¼þÖУ¬¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐë·ÅÔÚwhere×Ó¾äµÄĩβ;
¡¡¡¡from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐÈý¸öÒÔÉϵÄÁ¬½Ó²éѯ£¬ÄǾÍÐèҪѡÔñ½»²æ±í(intersection table)×÷Ϊ»ù´¡±í£¬½»²æ±íÊÇÖ¸ÄǸö±»ÆäËû±íËùÒýÓõıí;
¡¡¡¡¡ô²ÉÓð󶨱äÁ¿
¡¡¡¡¡ôÔÚWHEREÖо¡Á¿²»ÒªÊ¹ÓÃOR
¡¡¡¡¡ôÓÃEXISTSÌæ´úIN¡¢ÓÃNOT EXISTSÌæ´úNOT IN;
¡¡¡¡¡ô±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓüÆË㣺WHERE SAL*12>25000;
¡¡¡¡¡ôÓÃINÀ´Ìæ´úOR£º WHERE LOC_ID=10 OR LOC_ID=15 OR LOC_ID=20
¡¡¡¡¡ô±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓÃIS NULLºÍIS NOT NULL;
¡¡¡¡¡ô×ÜÊÇʹÓÃË÷ÒýµÄµÚÒ»¸öÁÐ;
¡¡¡¡¡ôÓÃUNION-ALLÌæ´úUNION;
¡¡¡¡¡ô±ÜÃâ¸Ä±äË÷ÒýÁеÄÀàÐÍ£ºSELECT...from EMP WHERE EMPNO='123'£¬ÓÉÓÚÒþʽÊý¾ÝÀàÐÍת»»£¬to_char(EMPNO)='123'£¬Òò´Ë£¬½«²»²ÉÓÃË÷Òý£¬Ò»°ãÔÚ²ÉÓÃ×Ö·û´®Æ´´Õ¶¯Ì¬SQLÓï¾ä³öÏÖ;
¡¡¡¡¡ô'!=' ½«²»Ê¹ÓÃË÷Òý;
¡¡¡¡¡ôÓÅ»¯GROUP BY;
¡¡¡¡¡ô±ÜÃâ´øÓÐLIKE²ÎÊýµÄͨÅä·û£¬LIKE '4YE%'ʹÓÃË÷Òý£¬µ«LIKE '%YE'²»Ê¹ÓÃË÷Òý
¡¡¡¡¡ô±ÜÃâʹÓÃÀ§ÄѵÄÕý¹æ±í´ïʽ£¬ÀýÈçselect * from customer where zipcode like "98___"£¬¼´±ãÔÚzipcodeÉϽ¨Á¢ÁËË÷Òý£¬ÔÚÕâÖÖÇé¿öÏÂÒ²»¹ÊDzÉÓÃ˳ÐòɨÃèµÄ·½Ê½¡£Èç¹û°ÑÓï¾ä¸Ä³Éselect * from customer where zipcode>"98000"£¬ÔÚÖ´Ðвéѯʱ¾Í»áÀûÓÃË÷ÒýÀ´²éѯ£¬ÏÔÈ»»á´ó´óÌá¸ßËÙ¶È;
¡¡¡¡¡ô¾¡Á¿Ã÷È·µÄÍê³ÉSQLÓï¾ä£¬¾¡Á¿ÉÙÈÃÊý¾Ý¿â¹¤×÷¡£±ÈÈçдSELECTÓï¾äʱ£¬ÐèÒª°Ñ²éѯµÄ×Ö¶ÎÃ÷È·Ö¸³ö±íÃû¡£¾¡Á¿²»ÒªÊ¹ÓÃSELECT *Óï¾ä¡£×éÖ¯SQLÓï¾äµÄʱºò£¬¾¡Á¿°´ÕÕÊý¾Ý¿âµÄÏ°¹ß½øÐÐ×éÖ¯
ÎÄÕ³ö´¦£ºhttp://database.ctocio.com.cn/160/9182660.shtml


Ïà¹ØÎĵµ£º

DB2 SQL ¾«Òª £¨³ÖÐø¸üÐÂÖÐ.......£©

----start
      ·²ÊÇÖªµÀÊý¾Ý¿âµÄÈ˶¼ÖªµÀSQL£¬·²ÊǶÔSQLÓÐÒ»µãÁ˽âµÄÈ˶¼¾õµÃSQLºÜ¼òµ¥£¬·²ÊÇÓÐÕâÖָоõµÄÈ˶¼ÊÇSQLµÃ³õ¼¶Óû§£¬ÒòΪËûѧ»áÁËÔö²éɾ¸Ä¾ÍÒÔΪÕâ¾ÍÊÇSQLµÄÈ«²¿¡£Ä¿Ç°µÄ´ó²¿·ÖÓ¦ÓÃÈí¼þ¶¼ÊÇÒÔÊý¾Ý¿âΪÖÐÐÄ£¬Ëæ×ÅÈí¼þµÄÔËÐУ¬Êý¾ÝÁ¿»áÔ½À´Ô½´ó¡£ÈçºÎÓüò½à¡¢¸ßЧµÄSQLÓï¾ä²Ù×÷Êý¾ÝÏÔµÃÔ½À ......

[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Áù)

±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Ò»)--αÁÐROWNUMʹÓü¼ÇÉ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(¶þ)--±êÁ¿×Ó²éѯ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Èý)--PackageµÄÓŵã
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(ËÄ)--ÅúÁ¿´¦Àí
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Îå)--µ÷Óô洢¹ý³Ì·µ»Ø½á¹û¼¯
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Áù)- ......

SQLÒ»¸ö´æ´¢¹ý³Ìµ÷ÓÃÁíÒ»¸ö´æ´¢¹ý³Ì »ñµÃ·µ»ØÖµÎÊÌâ

µÚÒ»ÖÖ·½·¨: ʹÓÃoutput²ÎÊý
USE AdventureWorks;
GO
IF OBJECT_ID ( 'Production.usp_GetList', 'P' ) IS NOT NULL
    DROP PROCEDURE Production.usp_GetList;
GO
CREATE PROCEDURE Production.usp_GetList @product varchar(40)
    , @maxprice money
    , ......

¶¨Ê±ÖØÆôSQL ServerºÍTomcat

¶¨Ê±ÖØÆôSQL ServerºÍTomcat
[http://hi.baidu.com/personnel/blog/item/020d5edf020a281248540306.html]
¶¨Ê±ÖØÆôSQL ServerºÍTomcat
2007-06-07 08:23
ÒÔǰûÓÐ×Ô¼º¹ÜÀí·þÎñÆ÷»¹²»ÖªµÀ£¬SQL Server·þÎñÆ÷µÄÄÚ´æËæ×ÅÔËÐеÄʱ¼äÔö³¤¶ø²»¶ÏÔö³¤¡£
ÓÃÁËÒ»Á½ÌìÖ®ºó·¢ÏÖ½ø³ÌÖеÄSQL ServerÒѾ­Õ¼ÓÃÁ˽ü1.3GµÄÄڴ棬ÄÚ´æÒ»¹ ......

sqlÐÔÄÜÓÅ»¯

1.²éѯµÄÄ£ºýÆ¥Åä
¾¡Á¿±ÜÃâÔÚÒ»¸ö¸´ÔÓ²éѯÀïÃæʹÓà LIKE '%parm1%'—— ºìÉ«±êʶλÖõİٷֺŻᵼÖÂÏà¹ØÁеÄË÷ÒýÎÞ·¨Ê¹Óã¬×îºÃ²»ÒªÓÃ.
½â¾ö°ì·¨:
ÆäʵֻÐèÒª¶Ô¸Ã½Å±¾ÂÔ×ö¸Ä½ø£¬²éѯËٶȱã»áÌá¸ß½ü°Ù±¶¡£¸Ä½ø·½·¨ÈçÏ£º
a¡¢ÐÞ¸Äǰ̨³ÌÐò——°Ñ²éѯÌõ¼þµÄ¹©Ó¦ÉÌÃû³ÆÒ»À¸ÓÉÔ­À´µÄÎı¾ÊäÈë¸ÄΪÏÂÀ­Áб ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ