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

sql unionÓ÷¨ºÍsql union allÓ÷¨,sql unionЧÂÊ

sql unionÓ÷¨ºÍsql union allÓ÷¨,sql unionЧÂÊ
1¡¢sql unionÓ÷¨
sql unionÔÚ²éѯÖпÉÒÔ½«Á½¸öSQL Óï¾äµÄ½á¹ûºÏ²¢ÆðÀ´¡£Èç¹ûÕâÑù¿´µÄ»°£¬ UNION ¸ú JOIN ÊÇÏàËƵģ¬Á½¸öÖ¸Á¿ÉÒÔÓɶà¸ö±í¸ñÖÐߢȡ×ÊÁÏ¡£
sql unionµÄÒ»¸öÏÞÖÆÊÇÁ½¸ö SQL Óï¾äËù²úÉúµÄÀ¸Î»ÐèÒªÊÇͬÑùµÄ×ÊÁÏÖÖÀà¡£ÁíÍ⣬µ±ÎÒÃÇÓà UNIONÕâ¸öÖ¸Áîʱ£¬ÎÒÃÇÖ»»á¿´µ½²»Í¬µÄ×ÊÁÏÖµ (ÀàËÆ SELECT DISTINCT)¡£
sql unionÖ»Êǽ«Á½¸ö½á¹ûÁª½áÆðÀ´Ò»ÆðÏÔʾ£¬²¢²»ÊÇÁª½áÁ½¸ö±í£¬sqlÓ÷¨ÈçÏ£º
Á½¸ö±í¸ñ£¬ StoreData_200903 ±í¸ñ StoreData_200904£¬ÕâÁ½Õűí¸ñµÄÊý¾Ý½á¹¹ÊÇÍêÈ«Ò»ÑùµÄ£¬Ö»ÊÇ´æ·ÅÁ˲»Í¬Ô·ݵÄÊý¾Ý¿â£¨×¢Ò⣺ÕâÑù×öÊÇΪÁËÄܹ»·Ö±í£¬¶øÇÒ¿ÉÒÔ°´Ô´浵Êý¾Ý£©£¬ÏÖÔÚÐèÒªÁªºÏ²éѯ£¬¾ÍÊÇ´ÓÁ½¸ö±íÖвéѯ³öÊý¾Ý£¬SQL Óï¾ä£º
SELECT top 50 from StoreData_200903
UNION
SELECT top 50 from StoreData_200904
2¡¢sql union allÓ÷¨
sql union allÕâ¸öÖ¸ÁîµÄÄ¿µÄÒ²ÊÇÒª½«Á½¸ö SQL Óï¾äµÄ½á¹ûºÏ²¢ÔÚÒ»Æð¡£ sql union allºÍ sql union²»Í¬Ö®´¦ÔÚÓÚ sql union all»á½«Ã¿Ò»´Î·ûºÏÌõ¼þµÄÊý¾ÝÁгöÀ´£¬ÎÞÂÛÊý¾Ý¿âÓÐÎÞÖظ´¡£
Ó÷¨Ò²ºÜ¼òµ¥£º
SELECT top 50 from StoreData_200903
UNION ALL
SELECT top 50 from StoreData_200904
ÖµµÃ×¢ÒâµÄÊÇ£¬sql union allµÄÖ´ÐÐЧÂÊÒª±Èsql unionЧÂÊÒª¸ßºÜ¶à£¬ÕâÊÇÒòΪ£¬Ê¹ÓÃsql unionÐèÒª½øÐÐÅÅÖØ£¬¶øsql union All ÊDz»ÐèÒªÅÅÖصģ¬ÕâÒ»µã·Ç³£ÖØÒª£¬ÒòΪ¶ÔÓÚһЩµ¥´¿µØʹÓ÷ֱíÀ´Ìá¸ßЧÂʵIJéѯ£¬ÍêÈ«¿ÉÒÔʹÓÃsql union All¡£
»¹ÓУ¬Èç¹ûʹÓÃÁËunion£¬ÎÞÂÛÊÇsql union»¹ÊÇsql union allÒ»¶¨Òª¼Çס¶ÔÊý¾Ý¿â±í¼ÓÉÏË÷Òý£¡
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ÔÚÊý¾Ý¿âÖУ¬unionºÍunion all ¹Ø¼ü×Ö¶¼Êǽ«Á½¸ö½á¹û¼¯ºÏºÏ²¢ÎªÒ»¸ö£¬µ«ÕâÁ½Õß´ÓʹÓúÍЧÂÊÉÏÀ´Ëµ¶¼ÓÐËù²»Í¬¡£
UNIONÔÚ½øÐбíÁ´½Óºó»áɸѡµôÖظ´µÄ¼Ç¼£¬ËùÒÔÔÚ±íÁ´½Óºó»á¶ÔËù²úÉúµÄ½á¹û¼¯½øÐÐÅÅÐòÔËË㣬ɾ³ýÖظ´µÄ¼Ç¼ÔÙ·µ»Ø½á¹û¡£Êµ¼Ê´ó²¿·ÖÓ¦ÓÃÖÐÊDz»»á²úÉúÖظ´µÄ¼Ç¼£¬×î³£¼ûµÄÊǹý³Ì±íÓëÀúÊ·±íUNION¡£È磺
select * from gc_dfys
union
select * from ls_jg_dfys
Õâ¸öSQLÔÚÔËÐÐʱÏÈÈ¡³öÁ½¸ö±íµÄ½á¹û£¬ÔÙÓÃÅÅÐò¿Õ¼ä½øÐÐÅÅÐòɾ³ýÖظ´µÄ¼Ç¼£¬×îºó·µ»Ø½á¹û¼¯£¬Èç¹û±íÊý¾ÝÁ¿´óµÄ»°¿ÉÄܻᵼÖÂÓôÅÅ̽øÐÐÅÅÐò¡£
¶øUNION ALLÖ»ÊǼòµ¥µÄ½«Á½¸ö½á¹ûºÏ²¢ºó¾Í·µ»Ø¡£ÕâÑù£¬Èç¹û·µ»


Ïà¹ØÎĵµ£º

¡¾×ܽ᡿oracle»Ö¸´Îóɾ³ýÊý¾Ý£¬½â³ýËø¶¨µÄµÈsqlÓï¾ä

1.Ôø¾­²»Ð¡ÐÄ°Ñ¿ª·¢¿âµÄÊý¾Ý¿â±íÈ«²¿É¾³ý£¬µ±Ê±ÏŵÄÒªËÀ¡£½á¹ûÕÒµ½ÏÂÃæµÄÓï¾ä»Ö¸´µ½ÁË1¸öСʱ֮ǰµÄÊý¾Ý£¡ºÜ¼òµ¥¡£
×¢ÒâʹÓùÜÀíÔ±µÇ¼ϵͳ£º
select * from ±íÃû as of timestamp sysdate-1/12 //²éѯÁ½¸öСʱǰµÄij±íÊý¾Ý£¡¼ÈÈ»Á½Ð¡Ê±ÒÔÇ°µÄÊý¾Ý¶¼µÃµ½ÁË£¬¼ÌÐøÔõô×ö£¬ÖªµÀÁË°É¡£¡£

Èç¹ûdropÁË±í£¬Ôõô°ì£¿£¿¼ûÏ ......

SQLÄ£ºý²éѯÓï·¨LIKE


Ö´ÐÐ Êý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºýÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥Åäģʽ£º
1£¬%£º±íʾÈÎÒâ0¸ö»ò¶à¸ö×Ö·û¡£¿ÉÆ¥ÅäÈÎÒâÀàÐͺͳ¤¶ÈµÄ×Ö·û£¬ÓÐЩÇé¿öÏÂÈôÊÇÖÐÎÄ£¬ÇëÔËÓÃÁ½¸ö°Ù·ÖºÅ£¨%%£©±íʾ¡£
±ÈÈç SELECT * from [user] WHERE u_na ......

oracle PL SQLѧϰ°¸Àý£¨¶þ£©

¡¾ÑµÁ·6.1¡¿¡¡Ê¹ÓÃÒþʽÓαêµÄÊôÐÔ£¬Åж϶ԹÍÔ±¹¤×ʵÄÐÞ¸ÄÊÇ·ñ³É¹¦¡£
²½Öè1£ºÊäÈëºÍÔËÐÐÒÔϳÌÐò£º
BEGIN
  UPDATE emp SET sal=sal+100 WHERE empno=1234;
  IF SQL%FOUND THEN
       DBMS_OUTPUT.PUT_LINE('³É¹¦Ð޸ĹÍÔ±¹¤×Ê£¡');
       ......

oracle PL SQLѧϰ°¸Àý£¨Èý£©

´æ´¢¹ý³Ì
========================================================================== 
========================================================================== 
¡¾ÑµÁ·15.1¡¿  ´´½¨Ò»¸öÏÔʾ¹ÍÔ±×ÜÈËÊýµÄ´æ´¢¹ý³Ì¡£
  ²½Öè1£ºµÇ¼SCOTTÕË»§(»òѧÉú¸öÈËÕË»§)¡£
  ²½Öè2£º ......

SQL server 2005(´æ´¢¹ý³Ì)


Ò»£®¸ÅÊö
   ´æ´¢¹ý³ÌÊÇÒ»×éÔ¤ÏȱàÒëºÃµÄT--SQL´úÂ룬ǿµ÷Ò»µã£ºÕâЩ´úÂëÊÇÔ¤±àÒëºÃµÄ£¬¼´ÔÚÖ´ÐÐʱ¾Í²»ÓÃÔÚ½øÐбàÒëÁË£¬ÕâÑù»áÌá¸ß³ÌÐòµÄÔËÐÐЧÂÊ¡£ËüÀàËÆÓÚÆäËû¸ß¼¶ÓïÑÔÀïµÄ¹ý³Ì£¬¼´Íê³ÉÌض¨¹¦Äܵĺ¯Êý¡£´æ´¢¹ý³Ì·ÖÁ½ÀࣺϵͳÌṩµÄ´æ´¢¹ý³Ì£¬Óû§×Ô¼º¶¨ÒåµÄ´æ´¢¹ý³Ì£¬ÏµÍ³¶¨ÒåµÄÒÔ sp_Ϊǰ׺¡£
¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ