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

SQL×Ö·û´®²Ù×÷º¯Êý´óÈ«

selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'ÔÆ',×Ö¶Î1£©=1;
×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´®ºÍ±í´ïʽִÐв»Í¬µÄÔËËã¡£´ËÀຯÊý×÷ÓÃÓÚCHAR¡¢VARCHAR¡¢ BINARY¡¢ ºÍVARBINARY Êý¾ÝÀàÐÍÒÔ¼°¿ÉÒÔÒþʽת»»ÎªCHAR »òVARCHARµÄÊý¾ÝÀàÐÍ¡£¿ÉÒÔÔÚSELECT Óï¾äµÄSELECT ºÍWHERE ×Ó¾äÒÔ¼°±í´ïʽÖÐʹÓÃ×Ö·û´®º¯Êý¡£
³£ÓõÄ×Ö·û´®º¯ÊýÓУº
Ò»¡¢×Ö·ûת»»º¯Êý
1¡¢ASCII()
·µ»Ø×Ö·û±í´ïʽ×î×ó¶Ë×Ö·ûµÄASCII ÂëÖµ¡£ÔÚASCII£¨£©º¯ÊýÖУ¬´¿Êý×ÖµÄ×Ö·û´®¿É²»ÓÑ’À¨ÆðÀ´£¬µ«º¬ÆäËü×Ö·ûµÄ×Ö·û´®±ØÐëÓÑ’À¨ÆðÀ´Ê¹Ó㬷ñÔò»á³ö´í¡£
2¡¢CHAR()
½«ASCII Âëת»»Îª×Ö·û¡£Èç¹ûûÓÐÊäÈë0 ~ 255 Ö®¼äµÄASCII ÂëÖµ£¬CHAR£¨£© ·µ»ØNULL ¡£
3¡¢LOWER()ºÍUPPER()
LOWER()½«×Ö·û´®È«²¿×ªÎªÐ¡Ð´£»UPPER()½«×Ö·û´®È«²¿×ªÎª´óд¡£
4¡¢STR()
°ÑÊýÖµÐÍÊý¾Ýת»»Îª×Ö·ûÐÍÊý¾Ý¡£
STR (<float_expression>[£¬length[£¬ <decimal>]])
length Ö¸¶¨·µ»ØµÄ×Ö·û´®µÄ³¤¶È£¬decimal Ö¸¶¨·µ»ØµÄСÊýλÊý¡£Èç¹ûûÓÐÖ¸¶¨³¤¶È£¬È±Ê¡µÄlength ֵΪ10£¬ decimal ȱʡֵΪ0¡£
µ±length »òÕßdecimal Ϊ¸ºÖµÊ±£¬·µ»ØNULL£»
µ±length СÓÚСÊýµã×ó±ß£¨°üÀ¨·ûºÅ룩µÄλÊýʱ£¬·µ»Ølength ¸ö*£»
ÏÈ·þ´Ólength £¬ÔÙÈ¡decimal £»
µ±·µ»ØµÄ×Ö·û´®Î»ÊýСÓÚlength £¬×ó±ß²¹×ã¿Õ¸ñ¡£
¶þ¡¢È¥¿Õ¸ñº¯Êý
1¡¢LTRIM() °Ñ×Ö·û´®Í·²¿µÄ¿Õ¸ñÈ¥µô¡£
2¡¢RTRIM() °Ñ×Ö·û´®Î²²¿µÄ¿Õ¸ñÈ¥µô¡£
Èý¡¢È¡×Ó´®º¯Êý
1¡¢left()
LEFT (<character_expression>£¬ <integer_expression>)
·µ»Øcharacter_expression ×óÆð integer_expression ¸ö×Ö·û¡£
2¡¢RIGHT()
RIGHT (<character_expression>£¬ <integer_expression>)
·µ»Øcharacter_expression ÓÒÆð integer_expression ¸ö×Ö·û¡£
3¡¢SUBSTRING()
SUBSTRING (<expression>£¬ <starting_ position>£¬ length)
·µ»Ø´Ó×Ö·û´®×ó±ßµÚstarting_ position ¸ö×Ö·ûÆðlength¸ö×Ö·ûµÄ²¿·Ö¡£
ËÄ¡¢×Ö·û´®±È½Ïº¯Êý
1¡¢CHARINDEX()
·µ»Ø×Ö·û´®ÖÐij¸öÖ¸¶¨µÄ×Ó´®³öÏֵĿªÊ¼Î»Öá£
CHARINDEX (<’substring_expression’>£¬ <expression>)
ÆäÖÐsubstring


Ïà¹ØÎĵµ£º

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

Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé:
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01','yyyy-mm-dd');
¡¡¡¡¡ôÔÚ¹ýÂËÌõ¼þÖУ¬¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐë·ÅÔÚwhere×Ó¾äµÄĩβ;
¡¡¡¡from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»× ......

SQL²éѯÖظ´Êý¾ÝºÍÇå³ýÖظ´Êý¾Ý


ÓÐÀý±í£ºemp
emp_no   name    age    
    001           Tom      17    
    002       &nb ......

SQL ×Ö·û´®²ð·Ö

       ÓÐÕâÑùÒ»¸ö×Ö·û´®(ÖÐ,¹ú,ÖÐ,ÈËÃñ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú)
´¦Àí¹ýÖ®ºó±ä³É(ÖÐ,¹ú,ÈËÃñ,ÏÖ´ú¹¤Òµ»¯½ø³Ì)
 
        ÒÔÏÂÊÇÎҵķ½·¨,ÓÐʲô²»¶ÔµÄµØ·½»¹Çë¸÷λָµã
 ------------------ɾ³ýÖظ´µÄ×Ö·û
 declare
@v1 nvarchar
......

ת£º³£ÓÃSQLÓï¾äÊéд¼¼ÇÉ

³£ÓÃSQLÓï¾äÊéд¼¼ÇÉ
×÷Õߣº   À´Ô´£ºjavaeye²©¿Í   ·¢²¼Õߣºadmin
ʱ¼ä£º2009-05-11 10:07:41   µã»÷£º2010
SQL½á¹¹»¯²éѯ×Ö·û´®µÄ¸Äд£¬ÊÇʵÏÖÊý¾Ý¿â²éѯÐÔÄÜÌáÉýµÄ×îÏÖʵ¡¢×îÓÐЧµÄÊֶΣ¬ÓÐʱÉõÖÁÊÇΨһµÄÊֶΣ¬±ÈÈçÔÚ²»ÔÊÐí´ó·ù¶ÈÐÞ¸ÄÏÖÓÐÊý¾Ý¿â½á¹¹µÄÇé¿öÏ¡£
ͨ¹ ......

Pl/sql µÄ×Ô¶¯ÌáʾºÍÌá½»£¨commit£©

×Ô¶¯ÌáʾµÄ¿ì½Ý¼ü£ºF6
¿ÉÒÔ¸ü¸Ä£ºTools->Preferences->User interface->Key Configuration ,ÔÚItemÁÐÀïÕÒµ½“Tools/Code Assistant”,ÔÚºóÃæ¶ÔÓ¦µÄ¿ì½Ý¸Ä³É×Ô¼ºÏ²»¶µÄ¡£
ĬÈÏÊDz»ÄÜ×Ô¶¯Ìá½»µÄ£¬°´ F10 ¼ü¿ÉÒÔÔÚ×ö¸ü¸ÄºóÌá½»¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ