SQLÊäÈëÊý¾Ý,Ö¸¶¨ÅÅÐò˳Ðò
·Ï»°²»¶à˵,ÉÏ´úÂë
SELECT k
from (
SELECT 'shanghai' AS k from DUAL
UNION ALL
SELECT 'dalian' AS k from DUAL
UNION ALL
SELECT 'beijing' AS k from DUAL
)
ORDER BY CASE
WHEN k = 'beijing'
THEN 1
WHEN k = 'dalian'
THEN 3
WHEN k = 'shanghai'
THEN 2
END
ÀûÓÃORDER BY µÄcaseÓï¾äÅäÖÃÅÅÐò˳ÐòºÅ.
µ±È»ÀûÓÃÀûÓòéѯ×Ó±í,»òunionµÈ·½Ê½Ò²¿ÉÒÔ,µ«ÊÇÕâ¸ö¿ÉÒÔ˵ÊÇ×î¼òµ¥,×î¸ßЧ·½·¨.
Ïà¹ØÎĵµ£º
ÎÒÃÇÏÈ¿´ NestedLoop ºÍ MergeJoin µÄËã·¨£¨ÒÔÏÂΪÒýÓ㬼û RicCC µÄ¡¶ ͨÍùÐÔÄÜÓÅ»¯µÄÌìÌà - µØÓü JOIN ·½·¨ËµÃ÷ ¡· ):
==================================
NestedLoop:
foreach rowA in tableA where tableA.col2=?
{
search rowsB from tableB where tab ......
ÏÈÕ¾ÔÚÓ¦ÓóÌÐòµÄ½Ç¶È˵˵ËüÃǵIJ»Í¬¡£
1¡¢ Ö±½ÓÆ´ SQL
¾ÍÏñ´ó¼ÒÁ˽âµÄÄÇÑù£¬Ö±½ÓÆ´ SQL ´øÀ´ÁË SQL ×¢Èë¹¥»÷£¬´øÀ´ÁËƴʱЩÐíµÄÐÔÄÜËðʧ£¬µ«ÊÇÆ´²»ÓÃÌí¼Ó SqlParameter £¬»áÉÙдºÜ¶à´úÂë——ºÜ¶àÈËϲ»¶Ö±½ÓÆ´£¬Ò²Ðí¾ÍÒòΪÕâµã¡£ÕâÖÖ×ö·¨»á°ÑÄãÆ´ºÃµÄ SQL ÔÑùÖ±½Ó·¢Ë͵½ DB ·þÎñÆ÷È¥Ö´ÐС££¨×¢ÒâÀàËÆ ......
SQL ÖеÄÖ÷¼üµÄ×÷ÓÃ:
Äܹ»Î¨Ò»±íʾÊý¾Ý±íÖеÄÿ¸ö¼Ç¼µÄ¡¾×ֶΡ¿»òÕß¡¾×ֶΡ¿µÄ×éºÏ¾Í³ÆΪÖ÷Âë(Ö÷¼ü)¡£
×÷ÓÃ
1¡¢Ö÷¼üΨһµÄʶ±ðÿһ¼Ç¼;
2¡¢Ö÷¼ü½«¼Ç¼ºÍ´æ·ÅÔÚÆäËû±íÖеÄÊý¾Ý½øÐйØÁª¡£ÔÚÕâÒ»µãÉÏ£¬Ö÷¼üÊDz»Í¬±íÖи÷¼Ç¼֮¼äµÄ¼òµ¥Ö¸Õë¡£
ÈôÓÐÁ½¸ö±íA£¬B£¬keyÊÇAµÄÖ÷¼ü£¬¶øBÖÐÒ²ÓÐkey×ֶΣ¬Ôòkey¾ÍÊDZíBµÄÍâ¼ü¡£
A ......
ORACLE SQLÐÔÄÜÓÅ»¯
ÎÒÒª½²µÄÌâÄ¿ÊÇOracle SQLÐÔÄÜÓÅ»¯£¬Ö»ÊÇOracleÐÔÄÜÓÅ»¯ÖеÄÒ»Ïî¡£OracleµÄÐÔÄÜÓÅ»¯°üº¬ºÜ¶à·½Ã棬±ÈÈçµ÷ÕûÎïÀí´æÈ¡£¬µ÷ÕûÂß¼´æÈ¡£¬µ÷ÕûÄÚ´æʹÓ㬼õÉÙÍøÂçÁ÷Á¿µÈ¡£ÕâÀïÑ¡ÔñSQLÐÔÄÜÓÅ»¯ÊÇÒòΪÕⲿ·ÖÄÚÈÝÎÒÃDzâÊÔÈËÔ±×îÈÝÒ×½Ó´¥µ½£¬ÁíÍ⿪·¢ÈËԱдSQL½Å±¾Ê±ÓÐʱºÜËæÒ⣬²»Öª²»¾õ¾Í»áÔì³É³ÌÐòÐÔÄÜÉϵÄÏ ......