×ðÁú¿­Ê±¹ÙÍøµÇ¼

sqlÖÐÌæ»»Ö¸¶¨Î»ÖõÄ×Ö·ûÔõôŪ

ÔÚ sql ÖУ¬Ê¹Óà substr() º¯ÊýÖ¸¶¨ÒªÌæ»»×Ö·ûµÄÆðʼλÖúͳ¤¶È£¬È»ºóʹÓà replace() º¯ÊýÌæ»»Ö¸¶¨Î»ÖõÄ×Ö·û£¬Ó﷨Ϊ replace(string, start, length, new_string)¡£

SQL ÖÐÌæ»»Ö¸¶¨Î»ÖõÄ×Ö·û

ÔÚ SQL ÖУ¬¿ÉÒÔʹÓà SUBSTR() º¯ÊýºÍ REPLACE() º¯ÊýÀ´Ìæ»»Ö¸¶¨Î»ÖõÄ×Ö·û¡£

Óï·¨

REPLACE(string, start, length, new_string)

µÇ¼ºó¸´ÖÆ

²ÎÊý

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

start£ºÒªÌæ»»×Ö·ûµÄÆðʼλÖã¨´Ó 1 ×îÏȼÆÊý£©¡£

length£ºÒªÌæ»»×Ö·ûµÄ³¤¶È¡£

new_string£ºÓÃÓÚÌæ»»µÄ×Ö·û´®¡£

ʾÀý

Ìæ»»×Ö·û´®ÖÐ´ÓµÚ 5 λ×îÏ鵀 3 ¸ö×Ö·ûΪ “ABC”:

SELECT REPLACE('Hello World', 5, 3, 'ABC');

µÇ¼ºó¸´ÖÆ

Êä³ö£º

Hello ABCld

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

SUBSTR() º¯Êý

SUBSTR() º¯Êý¿ÉÓÃÓÚÖ¸¶¨ÒªÌæ»»µÄ×Ö·ûµÄÆðʼλÖúͳ¤¶È£º

Óï·¨

SUBSTR(string, start, length)

µÇ¼ºó¸´ÖÆ

²ÎÊý

string£ºÒªÌáÈ¡×Ó×Ö·û´®µÄԭʼ×Ö·û´®¡£

start£ºÒªÌáÈ¡×Ó×Ö·û´®µÄÆðʼλÖã¨´Ó 1 ×îÏȼÆÊý£©¡£

length£ºÒªÌáÈ¡×Ó×Ö·û´®µÄ³¤¶È¡£

ʾÀý

ʹÓà SUBSTR() º¯ÊýÖ¸¶¨ÒªÌæ»»µÄ×Ó×Ö·û´®£º

SELECT REPLACE('Hello World', SUBSTR('Hello World', 5, 3), 'ABC');

µÇ¼ºó¸´ÖÆ

Êä³ö£º

Hello ABCld

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇsqlÖÐÌæ»»Ö¸¶¨Î»ÖõÄ×Ö·ûÔõôŪµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ