°Ë±¦Êé¿â > ÎÄѧÆäËûµç×ÓÊé > php³ÌÐòÉè¼Æ¼òÃ÷½Ì³Ì(DOC¸ñʽ) >

µÚ15²¿·Ö

php³ÌÐòÉè¼Æ¼òÃ÷½Ì³Ì(DOC¸ñʽ)-µÚ15²¿·Ö

С˵£º php³ÌÐòÉè¼Æ¼òÃ÷½Ì³Ì(DOC¸ñʽ) ×ÖÊý£º ÿҳ4000×Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡





¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡69¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

M¡¡¡¡£ºÖ¸³ö×î´óµÄÏÔʾ³ß´ç¡£×î´óµÄºÏ·¨µÄÏÔʾ³ß´çÊÇ¡¡¡¡255¡¡¡¡¡£¡¡¡¡¡¡¡¡

D¡¡¡¡£ºÊÊÓÃÓÚ¸¡µãÀàÐͲ¢ÇÒÖ¸³ö¸úËæÔÚÊ®½øÖÆСÊýµãºóµÄÊýÂëµÄÊýÁ¿¡£×î´ó¿ÉÄܵÄÖµÊÇ30£¬µ«ÊÇÓ¦¸Ã²»´óÓÚM¡­2¡£¡¡¡¡

·½À¨ºÅ£¨¡¡¡°£§¡±ºÍ¡°£§¡¡¡±£©Ö¸Ã÷ÆäÖеIJÎÊý¿ÉÑ¡¡£¡¡¡¡¡¡¡¡

×¢Ò⣬Èç¹û´øÉϲÎÊýZEROFILL£¬MySQL¡¡½«Îª¸ÃÁÐ×Ô¶¯µØÔö¼ÓUNSIGNED¡¡ÊôÐÔ¡£¡¡¡¡

¡¡£¨1£©Êý×ÖÀàÐÍ¡¡¡¡

TINYINT£§£¨M£©£§¡¡£§UNSIGNED£§¡¡£§ZEROFILL£§¡¡¡¡¡¡¡¡

΢ÕûÐÍ£¬Ò»¸öºÜСµÄÕûÊý¡£ÓзûºÅµÄ·¶Î§ÊÇ¡­128¡¡µ½127£¬ÎÞ·ûºÅµÄ·¶Î§ÊÇ0¡¡µ½255¡¡¡£¡¡¡¡´æ´¢Ê±Õ¼ÓÃÒ»¸ö×Ö½Ú¡£¡¡¡¡

INT£§£¨M£©£§¡¡£§UNSIGNED£§¡¡£§ZEROFILL£§¡¡¡¡¡¡¡¡

ÕûÐÍ£¬Ò»¸öÕý³£´óСÕûÊý¡£ÓзûºÅµÄ·¶Î§ÊÇ¡­2147483648¡¡µ½2147483647£¬ÎÞ·ûºÅµÄ·¶Î§ÊÇ0¡¡µ½4294967295¡¡¡£¡¡¡¡¡¡¡¡

´æ´¢Ê±Õ¼ÓÃ4¡¡¸ö×Ö½Ú¡£¡¡¡¡

FLOAT£§£¨M£»D£©£§¡¡£§ZEROFILL£§¡¡¡¡¡¡¡¡



ʵÐÍ£¬Ò»¸öС£¨µ¥¾«ÃÜ£©¸¡µãÊý×Ö¡£²»ÄÜÎÞ·ûºÅ¡£ÔÊÐíµÄÖµÊÇ¡­3¡£402823466E£«38¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡µ½¡­1¡£175494351E¡­38¡¡£¬0¡¡¡¡ºÍ¡¡

1¡£175494351E¡­38¡¡µ½3¡£402823466E£«38¡£M¡¡ÊÇÏÔʾ¿í¶È¶øD¡¡ÊÇСÊýµÄλÊý¡£¡¡¡¡¡¡¡¡

´æ´¢Ê±Õ¼ÓÃ4¡¡¸ö×Ö½Ú¡£¡¡¡¡

¡¡£¨2¡¡£©ÈÕÆÚʱ¼äÀàÐÍ¡¡¡¡

DATE¡¡¡¡¡¡¡¡

Ò»¸öÈÕÆÚ¡£Ö§³ÖµÄ·¶Î§ÊÇ'1000¡­01¡­01'µ½'9999¡­12¡­31'¡¡¡£MySQL¡¡ÒÔ'YYYY¡­MM¡­DD'¸ñʽÀ´ÏÔʾ¡¡DATE¡¡Öµ£¬µ«ÊÇÔÊ¡¡

ÐíÄãʹÓÃ×Ö·û´®»òÊý×Ö°ÑÖµ¸³¸øDATE¡¡ÁС£¡¡¡¡¡¡¡¡

´æ´¢Ê±Õ¼ÓÃ3¡¡¸ö×Ö½Ú¡£¡¡¡¡

DATETIME¡¡¡¡¡¡¡¡

Ò»¸öÈÕÆÚºÍʱ¼ä×éºÏ¡£Ö§³ÖµÄ·¶Î§ÊÇ'1000¡­01¡­01¡¡00£º00£º00'µ½'9999¡­12¡­31¡¡23£º59£º59'¡£MySQL¡¡ÒÔ'YYYY¡­MM¡­DD¡¡¡¡

HH£ºMM£ºSS'¸ñʽÀ´ÏÔʾDATETIME¡¡Öµ£¬µ«ÊÇÔÊÐíÄãʹÓÃ×Ö·û´®»òÊý×Ö°ÑÖµ¸³¸øDATETIME¡¡µÄÁС£¡¡¡¡¡¡¡¡

´æ´¢Ê±Õ¼ÓÃ8¡¡¸ö×Ö½Ú¡£¡¡¡¡

¡¡£¨3£©×Ö·ûÀàÐÍ¡¡¡¡

CHAR£¨M£©¡¡¡¡¡¡¡¡



Ò»¸ö¶¨³¤×Ö·û´®£¬µ±´æ´¢Ê±£¬×ÜÊÇÊÇÓÿոñÌîÂúÓұߵ½Ö¸¶¨µÄ³¤¶È¡£M¡¡µÄ·¶Î§ÊÇ1¡¡¡¡¡«¡¡¡¡255¡¡¸ö×Ö·û¡£µ±Öµ±»¼ìË÷¡¡

ʱ£¬¿Õ¸ñβ²¿±»É¾³ý¡£CHAR¡¡Öµ¸ù¾Ýȱʡ×Ö·û¼¯ÒÔ´óСд²»Çø·ÖµÄ·½Ê½ÅÅÐòºÍ±È½Ï£¬³ý·Ç¸ø³öBINARY¡¡¹Ø¼ü´Ê¡£¡¡

CHAR¡¡ÊÇCHARACTER¡¡µÄÒ»¸öËõд¡£¡¡¡¡¡¡¡¡

´æ´¢Ê±Õ¼ÓÃM¡¡¸ö×Ö½Ú¡£¡¡¡¡

VARCHAR£¨M£©¡¡¡¡¡¡¡¡

Ò»¸ö±ä³¤×Ö·û´®¡£×¢Ò⣺µ±Öµ±»´æ´¢Ê±£¬Î²²¿µÄ¿Õ¸ñ±»É¾³ý¡£M¡¡µÄ·¶Î§ÊÇ1¡¡¡¡¡«¡¡¡¡255¡¡¸ö×Ö·û¡£¡¡¡¡VARCHAR¡¡ÖµÒÔ¡¡

´óСд²»Çø·ÖµÄ·½Ê½ÅÅÐòºÍ±È½Ï£¬³ý·Ç¸ø³öBINARY¡¡¹Ø¼ü´ÊÖµ¡£VARCHAR¡¡ÊÇCHARACTER¡¡VARYING¡¡Ò»¸öËõ¡¡

д¡£¡¡¡¡

´æ´¢Ê±Õ¼ÓÃL£«1¡¡¡¡×Ö½Ú£»¡¡¡¡ÔÚ´ËL¡¡¡¡select¡¡102/£¨1¡­1£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡NULL¡¡¡¡

¡¡£¨3£©Âß¼­ÔËËã¡¡¡¡

ËùÓеÄÂß¼­º¯Êý·µ»Ø1¡¡¡¡£¨TRUE¡¡£©»ò0¡¡¡¡£¨FALSE£©¡£¡¡¡¡NULL¡¡±»ÈÏΪÊǼÙÖµ¡£¡¡¡¡

NOT¡¡¡¡¡¡£¨£¡¡¡¡¡£©Âß¼­·Ç¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡PHP¡¡½²Òå¡¡¡¡¡¡¡¡µÚ¡¡¡¡70¡¡¡¡Ò³¡¡¡¡¹²¡¡¡¡90¡¡¡¡Ò³¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡71¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

OR¡¡¡¡¡¡¡¡¡¡£¨£ü£ü£©Âß¼­»ò¡¡¡¡¡¡¡¡

AND¡¡¡¡¡¡¡¡£¨&&£©Âß¼­Óë¡¡¡¡

¡¡£¨4¡¡£©±È½ÏÔËËã·û¡¡¡¡

±È½Ï²Ù×÷µÃ³öÖµ1¡¡¡¡£¨TRUE¡¡£©¡¢0¡¡¡¡£¨FALSE£©»òNULL¡¡µÈ½á¹û¡£ÕâЩº¯Êý¹¤×÷ÔËÓÃÔÚÊý×ÖºÍ×Ö·û´®ÉÏ¡£¡¡¡¡

=¡¡¡¡µÈÓÚ¡¡¡¡

²»µÈÓÚ¡¡¡¡

£¡=¡¡¡¡²»µÈÓÚ¡¡¡¡

=¡¡¡¡´óÓÚ»òµÈÓÚ¡¡¡¡

¡·¡¡¡¡´óÓÚ¡¡¡¡

mysql¡·¡¡select¡¡2¡¡¡·¡¡2£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡¡¡

IS¡¡NULL¡¡¡¡ÊÇ·ñΪ¿Õ¡¡¡¡

IS¡¡NOT¡¡NULL¡¡¡¡ÊÇ·ñ²»Îª¿Õ¡¡¡¡

mysql¡·¡¡select¡¡1¡¡IS¡¡NULL£»¡¡0¡¡IS¡¡NULL£»¡¡NULL¡¡IS¡¡NULL£º¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡0¡¡1¡¡¡¡

expr¡¡BETWEEN¡¡min¡¡AND¡¡max¡¡¡¡¡¡¡¡



Èç¹ûexpr¡¡¶Ô´óÓÚ»òµÈÓÚmin¡¡ÇÒexpr¡¡ÊÇСÓÚ»òµÈÓÚmax£¬BETWEEN¡¡·µ»Ø1£¬·ñÔòËü·µ»Ø0¡£¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡1¡¡BETWEEN¡¡2¡¡AND¡¡3£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡¡¡

mysql¡·¡¡select¡¡2¡¡BETWEEN¡¡2¡¡AND¡¡'3'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

expr¡¡IN¡¡£¨value£»¡£¡£¡££©¡¡¡¡¡¡¡¡

Èç¹ûexpr¡¡ÊÇÔÚIN¡¡±íÖеÄÈκÎÖµ£¬·µ»Ø1£¬·ñÔò·µ»Ø0¡£Èç¹ûËùÓеÄÖµÊdz£Êý£¬ÄÇôËùÓеÄÖµ¸ù¾Ýexpr¡¡ÀàÐͱ»¼Æ¡¡

ËãºÍÅÅÐò£¬È»ºóÏîÄ¿µÄËÑË÷ÊÇÓöþ½øÖƵÄËÑË÷Íê³É¡£ÕâÒâζ×ÅÈç¹ûIN¡¡Öµ±íÈ«²¿Óɳ£Êý×é³É£¬IN¡¡ÊǺܿìµÄ¡£Èç¹û¡¡

expr¡¡ÊÇÒ»¸ö´óСдÃô¸ÐµÄ×Ö·û´®±í´ïʽ£¬×Ö·û´®±È½ÏÒÔ´óСдÃô¸Ð·½Ê½Ö´ÐС£¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡2¡¡IN¡¡£¨0£»3£»5£»'wefwf'£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡¡¡

mysql¡·¡¡select¡¡'wefwf'¡¡IN¡¡£¨0£»3£»5£»'wefwf'£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡¡¡¡¡

expr¡¡NOT¡¡IN¡¡£¨value£»¡£¡£¡££©¡¡¡¡¡¡¡¡

ÓëNOT¡¡£¨expr¡¡IN¡¡£¨value£»¡£¡£¡££©£©Ïàͬ¡£¡¡¡¡¡¡¡¡

¡¡¡¡

ISNULL£¨expr£©¡¡¡¡¡¡¡¡

Èç¹ûexpr¡¡ÊÇNULL£¬ISNULL£¨£©·µ»Ø1£¬·ñÔòËü·µ»Ø0¡£¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡ISNULL£¨1£«1£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡¡¡

mysql¡·¡¡select¡¡ISNULL£¨1/0£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

¡¡¡¡

×¢Ò⣬ʹÓÃ=µÄNULL¡¡µÄÖµ±È½Ï×ÜΪ¼Ù£¡¡¡¡¡¡¡¡¡

¡¡¡¡

¡¡£¨5£©×Ö·û´®±È½Ïº¯Êý¡¡¡¡

ͨ³££¬Èç¹ûÔÚ×Ö·û´®±È½ÏÖеÄÈκαí´ïʽÊÇÇø·Ö´óСдµÄ£¬±È½ÏÒÔ´óСдÃô¸ÐµÄ·½Ê½Ö´ÐС£¡¡¡¡¡¡¡¡

expr¡¡LIKE¡¡pat¡¡tern£§ESCAPE¡¡'escape¡­char'£§¡¡¡¡¡¡¡¡

½«expr¡¡Óëģʽ×Ö·û´®pattern¡¡½øÐÐģʽƥÅä¡£·µ»Ø¡¡1¡¡¡¡£¨TRUE¡¡£©»ò0¡¡¡¡£¨FALSE£©¡£ÓÃLIKE£¬Äã¿ÉÒÔÔÚģʽÖÐʹÓá¡

ÏÂÁÐ2¡¡¸ö¢Ù£¥¡¡¡¡¡¡¡¡Æ¥ÅäÈκÎÊýÄ¿µÄ×Ö·û£¬ÉõÖÁÁã¸ö×Ö·û¡¡¡¡¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡PHP¡¡½²Òå¡¡¡¡¡¡¡¡µÚ¡¡¡¡71¡¡¡¡Ò³¡¡¡¡¹²¡¡¡¡90¡¡¡¡Ò³¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡72¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¢Ú_¡¡¡¡¡¡¡¡¾«È·Æ¥ÅäÒ»¸ö×Ö·û¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡'David£¡'¡¡LIKE¡¡'David_'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

mysql¡·¡¡select¡¡'David£¡'¡¡LIKE¡¡'£¥D£¥v£¥'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

¡¡¡¡

ΪÁ˲âÊÔÒ»¸öͨÅä·ûµÄÎÄ×ÖʵÀý£¬ÓÃתÒå×Ö·ûµÄ¼ÓÔÚ×Ö·ûÇ°Ãæ¡£Èç¹ûÄã²»Ö¸¶¨ESCAPE¡¡×Ö·û£¬¼Ù¶¨Îª¡°¡¡¡±£º¡¡¡¡¡¡¡¡

¡¡¡¡

£¥¡¡¡¡¡¡¡¡Æ¥Å䣥×Ö·û¡¡¡¡¡¡¡¡

_¡¡¡¡¡¡¡¡Æ¥Åä_×Ö·û¡¡¡¡¡¡¡¡

¡¡¡¡

mysql¡·¡¡select¡¡'David£¡'¡¡LIKE¡¡'David_'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡¡¡

mysql¡·¡¡select¡¡'David_'¡¡LIKE¡¡'David_'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

¡¡¡¡

ΪÁËÖ¸¶¨Ò»¸ö²»Í¬µÄתÒå×Ö·û£¬Ê¹ÓÃESCAPE¡¡×Ӿ䣺¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡'David_'¡¡LIKE¡¡'David£ü_'¡¡ESCAPE¡¡'£ü'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

¡¡¡¡

LIKE¡¡ÔÊÐíÓÃÔÚÊý×ֵıí´ïʽÉÏ£¡£¨ÕâÊÇMySQL¡¡¶ÔANSI¡¡SQL¡¡LIKE¡¡µÄÒ»¸öÀ©³ä¡££©¡¡¡¡¡¡¡¡

¡¡¡¡

mysql¡·¡¡select¡¡10¡¡LIKE¡¡'1£¥'£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

¡¡¡¡

expr¡¡NOT¡¡LIKE¡¡pattern¡¡£§ESCAPE¡¡'escape¡­char'£§¡¡¡¡¡¡¡¡

ÓëNOT¡¡£¨expr¡¡LIKE¡¡pattern£§ESCAPE¡¡'escape¡­char'£§£©Ïàͬ¡£¡¡¡¡¡¡¡¡

¡¡¡¡£¨6¡¡£©¿ØÖÆÁ÷º¯Êý¡¡¡¡

IF£¨expr1£»expr2£»expr3£©¡¡¡¡¡¡¡¡

Èç¹ûexpr1¡¡ÊÇTRUE£¨expr10¡¡ÇÒexpr1NULL£©£¬ÄÇôIF£¨£©·µ»Øexpr2£¬·ñÔòËü·µ»Øexpr3¡¡¡£IF£¨£©·µ»ØÒ»¸öÊý×Ö¡¡

»ò×Ö·û´®Öµ£¬È¡¾öÓÚËü±»Ê¹ÓõÄÉÏÏÂÎÄ¡£¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡IF£¨1¡·2£»2£»3£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡3¡¡¡¡

mysql¡·¡¡select¡¡IF£¨1¡¡'yes'¡¡¡¡

mysql¡·¡¡select¡¡IF£¨strcmp£¨'test'£»'test1'£©£»'yes'£»'no'£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡'no'¡¡¡¡

expr1¡¡×÷ΪÕûÊýÖµ±»¼ÆË㣬ËüÒâζ×ÅÈç¹ûÄãÕýÔÚ²âÊÔ¸¡µã»ò×Ö·û´®Öµ£¬Ó¦¸ÃʹÓÃÒ»¸ö±È½Ï²Ù×÷À´×ö¡£¡¡¡¡¡¡¡¡

mysql¡·¡¡select¡¡IF£¨0¡£1£»1£»0£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡0¡¡¡¡

mysql¡·¡¡select¡¡IF£¨0¡£10£»1£»0£©£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡1¡¡¡¡

ÔÚÉÏÃæµÄµÚÒ»ÖÖÇé¿öÖУ¬IF£¨0¡£1£©·µ»Ø0£¬ÒòΪ0¡£1¡¡±»±ä»»µ½ÕûÊýÖµ£»¡¡¡¡µ¼Ö²âÊÔIF£¨0£©¡£Õâ¿ÉÄܲ»ÊÇÄãÆÚÍûµÄ¡£ÔÚµÚ¡¡

¶þÖÖÇé¿öÖУ¬±È½Ï²âÊÔÔ­À´µÄ¸¡µãÖµ¿´ËüÊÇ·ñÊÇ·ÇÁ㣬±È½ÏµÄ½á¹û±»ÓÃ×÷Ò»¸öÕûÊý¡£¡¡¡¡¡¡¡¡

CASE¡¡value¡¡WHEN¡¡£§pare¡­value£§¡¡THEN¡¡result¡¡£§WHEN¡¡£§pare¡­value£§¡¡THEN¡¡result¡¡¡£¡£¡££§¡¡£§ELSE¡¡result£§¡¡¡¡

END¡¡¡¡¡¡¡¡

CASE¡¡WHEN¡¡£§condition£§¡¡THEN¡¡result¡¡£§WHEN¡¡£§condition£§¡¡THEN¡¡result¡¡¡£¡£¡££§¡¡£§ELSE¡¡result£§¡¡END¡¡¡¡¡¡¡¡

µÚÒ»¸ö°æ±¾·µ»Ø¡¡result£¬ÆäÖÐvalue=pare¡­value¡£µÚ¶þ¸ö°æ±¾ÖÐÈç¹ûµÚÒ»¸öÌõ¼þΪÕ棬·µ»Øresult¡£Èç¹ûû¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡PHP¡¡½²Òå¡¡¡¡¡¡¡¡µÚ¡¡¡¡72¡¡¡¡Ò³¡¡¡¡¹²¡¡¡¡90¡¡¡¡Ò³¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡73¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

ÓÐÆ¥ÅäµÄresult¡¡Öµ£¬ÄÇô½á¹ûÔÚELSE¡¡ºóµÄresult¡¡±»·µ»Ø¡£Èç¹ûûÓÐELSE¡¡²¿·Ö£¬ÄÇôNULL¡¡±»·µ»Ø¡£¡¡¡¡¡¡¡¡

mysql¡·¡¡SELECT¡¡CASE¡¡1¡¡WHEN¡¡1¡¡THEN¡¡¡¨one¡¨¡¡WHEN¡¡2¡¡THEN¡¡¡¨two¡¨¡¡ELSE¡¡¡¨more¡¨¡¡END£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡¡¨one¡¨¡¡¡¡

mysql¡·¡¡SELECT¡¡CASE¡¡WHEN¡¡1¡·0¡¡THEN¡¡¡¨true¡¨¡¡ELSE¡¡¡¨false¡¨¡¡END£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡¡¨true¡¨¡¡¡¡

mysql¡·¡¡SELECT¡¡CASE¡¡BINARY¡¡¡¨B¡¨¡¡when¡¡¡¨a¡¨¡¡then¡¡1¡¡when¡¡¡¨b¡¨¡¡then¡¡2¡¡END£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­¡·¡¡NULL¡¡¡¡

¡¡¡¡£¨7£©Êýѧº¯Êý¡¡¡¡

ËùÓеÄÊýѧº¯ÊýÔÚÒ»¸ö³ö´íµÄÇé¿öÏ·µ»ØNULL¡£¡¡¡¡¡¡¡¡

ABS£¨X£©¡¡¡¡¡¡¡¡



·µ»ØX¡¡µÄ¾ø¶ÔÖµ¡£¡¡¡¡¡¡¡¡

SIGN£¨X£©¡¡¡¡¡¡¡¡



·µ»Ø²ÎÊýµÄ·ûºÅ£¬Îª¡­1¡¢0¡¡»ò1£¬È¡¾öÓÚX¡¡ÊÇ·ñÊǸºÊý¡¢Áã»òÕýÊý¡£¡¡¡¡¡¡¡¡

MOD£¨N£»M£©¡¡¡¡¡¡¡¡

£¥¡¡¡¡¡¡¡¡



Ä£¡¡¡¡£¨ÀàË

·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©

Äã¿ÉÄÜϲ»¶µÄ