ms sql case when elseÓï¾äʹÓü¼ÇÉ
¹¤×÷ÖÐÅöµ½µÄС¼¼ÇÉ£¬±ÈÈç˵ҪÓÃÊý¾Ý±íÀïÈ¡³ö×¢²áÓû§µÄ×ÊÁÏ£¬ÐÔ±ðΪ1ÔòÏÔʾΪÄÐÉú£»ÐÔ±ðΪ2ÔòÏÔʾΪŮÉú£»ÒÔÇ°¶¼ÊÇ´Ó±íÀïÈ¡³öÊý¾Ý£¬È»ºóÔÙÓôúÂë½øÐÐÅжϣ¬Îª1ÔòÏÔʾΪÄÐÉú£»Îª2ÔòÏÔʾΪŮÉú£»Æäʵµ¥ÓÃSQLÓï¾ä¾Í¿ÉÒÔ×öµ½£¬ÈçÏ£º
Ö±½ÓʹÓÃcase when else Óï¾ä
Case¾ßÓÐÁ½ÖÖ¸ñʽ¡£¼òµ¥Caseº¯ÊýºÍCaseËÑË÷º¯Êý¡£
¼òµ¥Caseº¯Êýд·¨
CASE sex
WHEN '1' THEN 'ÄÐ'
WHEN '2' THEN 'Å®'
ELSE 'ÆäËû' END AS XX--ÁÙʱÌí¼ÓµÄ×Ö¶ÎÃû
--Áé»îCaseº¯Êýд·¨
CASE WHEN sex = '1' THEN 'ÄÐ'
WHEN sex = '2' THEN 'Å®'
ELSE 'ÆäËû' END AS XX--ÁÙʱÌí¼ÓµÄ×Ö¶ÎÃû
Á½ÖÖд·¨¾ùÄÜʵÏÖͬÑùµÄ¹¦ÄÜ£¬Ö»ÊǵڶþÖÖд·¨Áé»îÐÔ¸üÇ¿£¬¿ÉÒÔ¶à¸öÌõ¼þ½øÐÐÅжϣ¬È磺WHEN X>Y AND Z<G then,¶øʹÓõÚÒ»ÖÖд·¨¾ÍÎÞ·¨×öµ½¡£
Ïà¹ØÎĵµ£º
exists £¨sql ·µ»Ø½á¹û¼¯ÎªÕ棩
not exists (sql ²»·µ»Ø½á¹û¼¯ÎªÕ棩
ÈçÏ£º
±íA
ID NAME
1 A1
2 A2
3 A3
±íB
ID AID NAME
1 1 B1
2 2 B2
3 2 B3
±íAºÍ±íBÊÇ£±¶Ô¶àµÄ¹Øϵ A.ID => B.AID
......
ÐèÇó£ºÓÐexcelÎļþ£¬º¬¶à¸ösheet£¬Ã¿¸ösheetµÄÄÚÈݶÔÓ¦²åÈëµ½Ò»ÕÅ±í£¬sheetµÄÃû³Æ¾ÍÊǶÔÓ¦µÄ±íÃû³Æ¡£
ÿһÐÐΪÁÐÃû£¬ÀýÈ磺
´ï³É£º½«Ã¿¸ösheetÊä³ö³ÉÒ»¸öÒÔsheetÃû³ÆÃüÃûµÄsqlÎļþ£¬ÄÚÈÝΪÿÐÐÄÚÈݵÄinsertÓï¾ä¡£
ÒÔÉÏͼΪÀý»áÉú³ÉÈý¸ösqlÎļþ£¬·Ö±ðÊÇTF_R_TERMINAL_ARCH.sql£¬ TF_R_STOCK_TRADE.sql ºÍ TF_R_STOC ......
Ò»¡¢ SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºó ......
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦À ......
Insert Into Êý¾Ý±íÃû³Æ(×Ö¶ÎÃû³Æ1,×Ö¶ÎÃû³Æ2,...) values(×Ö¶ÎÖµ1,×Ö¶ÎÖµ2,...)
insert into user(username,password,age) values('ÀîÀÏËÄ','6666',45)
Update Êý¾Ý±íÃû³Æ Set ×Ö¶ÎÃû³Æ=×Ö¶ÎÖµ,×Ö¶ÎÃû³Æ=×Ö¶ÎÖµ,...[Where Ìõ¼þ]
Delete from Êý¾Ý±í
ÏÂÁвéѯ·µ»ØÔÚLONDON£¨Â׶أ©»òSEATTLE£¨Î÷ÑÅͼ£©µÄËùÓйÍÔ±£º
S ......