尊龙凯时人生就是博

mysqlÖÐreplaceº¯ÊýµÄʹÓÃÒªÁì

mysql ÖÐµÄ replace() º¯ÊýÓÃÓÚÌæ»»×Ö·û´®ÖеÄ×Ö·û»ò×Ó×Ö·û´®£¬ÆäÓ﷨Ϊ£ºreplace(string, search_string, replace_string)¡£ËüÖ§³ÖͬʱÌæ»»¶à¸ö×Ó×Ö·û´®¡¢Ê¹ÓÃÕýÔò±í´ïʽ¾ÙÐÐÌæ»»ºÍÌæ»»¿ÕÖµ¡£ÀýÈ磬ÒÔÏÂʾÀý½«×Ö·û´®ÖÐµÄ “apple” Ì滻Ϊ “banana”£ºselect replace(‘i love apple’, ‘apple’, ‘banana’);

MySQL ÖÐ REPLACE() º¯ÊýµÄʹÓÃ

REPLACE() º¯ÊýÓÃÓÚÌæ»»×Ö·û´®ÖеÄ×Ö·û»ò×Ó×Ö·û´®¡£ÆäÓï·¨ÈçÏ£º

REPLACE(string, search_string, replace_string)

µÇ¼ºó¸´ÖÆ

²ÎÊý˵Ã÷£º

string£ºÐèÒªÌæ»»×Ö·ûµÄ×Ö·û´®¡£

search_string£ºÒª±»Ìæ»»µÄ×Ó×Ö·û´®¡£

replace_string£ºÓÃÓÚÌæ»» search_string µÄÐÂ×Ó×Ö·û´®¡£

ʹÓÃʾÀý£º

ÒÔÏÂʾÀý½«×Ö·û´®ÖÐµÄ “Apple” Ì滻Ϊ “Banana”£º

SELECT REPLACE('I love Apple', 'Apple', 'Banana');

µÇ¼ºó¸´ÖÆ

Êä³ö£º

I love Banana

µÇ¼ºó¸´ÖÆ

ÆäËûÓ÷¨£º

1. Ìæ»»¶à¸ö×Ó×Ö·û´®

REPLACE() º¯Êý¿ÉÒÔͬʱÌæ»»¶à¸ö×Ó×Ö·û´®¡£ÀýÈ磬ÒÔÏÂÓï¾ä½«×Ö·û´®ÖÐµÄ “a” ºÍ “e” Ì滻Ϊ “o”£º

SELECT REPLACE('apple', 'a', 'o')
SELECT REPLACE('apple', 'e', 'o')

µÇ¼ºó¸´ÖÆ

Êä³ö£º

opple
oploe

µÇ¼ºó¸´ÖÆ

2. ʹÓÃÕýÔò±í´ïʽ

REPLACE() º¯ÊýÖ§³ÖʹÓÃÕýÔò±í´ïʽ¾ÙÐÐÌæ»»¡£ÀýÈ磬ÒÔÏÂÓï¾ä½«×Ö·û´®ÖÐËùÓÐÊý×ÖÌ滻Ϊ “*”£º

SELECT REPLACE('12345', '[0-9]', '*')

µÇ¼ºó¸´ÖÆ

Êä³ö£º

*****

µÇ¼ºó¸´ÖÆ

3. Ìæ»»¿ÕÖµ

REPLACE() º¯Êý¿ÉÒÔÓÃÓÚÌæ»»¿ÕÖµ¡£ÀýÈ磬ÒÔÏÂÓï¾ä½«×Ö·û´®ÖеĿÕÖµÌ滻Ϊ “N/A”£º

SELECT REPLACE(NULL, NULL, 'N/A')

µÇ¼ºó¸´ÖÆ

Êä³ö£º

N/A

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇmysqlÖÐreplaceº¯ÊýµÄʹÓÃÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ