×ðÁú¿­Ê±

sqlÖÐlpadº¯ÊýÓ÷¨

sql ÖÐ lpad º¯ÊýÓÃÓÚÔÚ×Ö·û´®×ó²àÌî³ä×Ö·ûÒÔµÖ´ïÖ¸¶¨³¤¶È¡£Óï·¨£ºlpad(source_string, target_length, pad_string)£¬ÆäÖÐ source_string Ϊԭʼ×Ö·û´®£¬target_length ΪĿµÄ³¤¶È£¬pad_string ΪÌî³ä×Ö·û¡£ÀýÈ磬lpad(‘²âÊÔ’, 10, ‘0’) ½«ÔÚ ‘²âÊÔ’ ×ó²àÌî³ä 5 ¸ö ‘0’£¬ÒԵִﳤ¶ÈΪ 10 µÄ×Ö·û´® ‘00000²âÊÔ’¡£

SQL ÖÐ LPAD º¯ÊýÓ÷¨

LPAD º¯ÊýÓÃÓÚÔÚ×Ö·û´®µÄ×ó²àÌî³äÖ¸¶¨ÃüÄ¿µÄ×Ö·û¡£ËüÊÇÒ»ÖÖÃûÌû¯×Ö·û´®µÄÊÊÓú¯Êý£¬Í¨³£ÓÃÓÚ¶ÔÆëÎı¾»ò½¨ÉèÀο¿³¤¶ÈµÄ×Ö·û´®¡£

Óï·¨

LPAD(source_string, target_length, pad_string)

µÇ¼ºó¸´ÖÆ

ÆäÖУº

source_string£ºÒªÌî³äµÄԭʼ×Ö·û´®¡£

target_length£ºÌî³äºó×Ö·û´®µÄÄ¿µÄ³¤¶È¡£

pad_string£ºÓÃÓÚÌî³äµÄ×Ö·û¡£

Ó÷¨

LPAD º¯Êýͨ¹ýÔÚ×Ö·û´®µÄ×ó²àÌí¼ÓÖظ´µÄ pad_string ×Ö·ûÀ´Ìî³ä×Ö·û´®¡£ÈôÊÇԭʼ×Ö·û´®µÄ³¤¶È´óÓÚÄ¿µÄ³¤¶È£¬Ôòº¯Êý»á½Ø¶Ïԭʼ×Ö·û´®ÒÔÆ¥ÅäÄ¿µÄ³¤¶È¡£

ÒÔÏÂʾÀýÑÝʾÁË LPAD º¯ÊýµÄÓ÷¨£º

SELECT LPAD('²âÊÔ', 10, '0') AS ÃûÌû¯×Ö·û´®;

µÇ¼ºó¸´ÖÆ

Êä³ö£º

ÃûÌû¯×Ö·û´®
00000²âÊÔ

µÇ¼ºó¸´ÖÆ

ÔÚ´ËʾÀýÖУ¬Ô­Ê¼×Ö·û´®Îª ‘²âÊÔ’£¬Ä¿µÄ³¤¶ÈΪ 10£¬Ìî³ä×Ö·ûΪ ‘0’¡£LPAD º¯ÊýÔÚ ‘²âÊÔ’ µÄ×ó²àÌî³äÁË 5 ¸ö ‘0’ ×Ö·û£¬Ê¹Æ䳤¶ÈµÖ´ï 10 ¸ö×Ö·û¡£

ʾÀý

ϱíÁгöÁ˸ü¶à LPAD º¯ÊýµÄʾÀý£º

Ô´×Ö·û´® Ä¿µÄ³¤¶È Ìî³ä×Ö·û Êä³ö
‘123’ 5 ‘0’ ‘00123’
‘ʾÀý’ 15 ‘ ‘ ‘ ʾÀý’
‘ºÜ³¤ºÜ³¤µÄ×Ö·û´®’ 20 ‘_’ ‘_ºÜ³¤ºÜ³¤µÄ×Ö·û´®’

½áÂÛ

LPAD º¯ÊýÊÇÒ»¸öÓÐÓõÄÃûÌû¯×Ö·û´®º¯Êý£¬¿ÉÓÃÓÚÔÚ×Ö·û´®µÄ×ó²àÌî³äÖ¸¶¨ÃüÄ¿µÄ×Ö·û¡£Í¨¹ýµ÷½â target_length ºÍ pad_string ¿ÉÒÔÎÞаµØ¿ØÖÆÌî³äµÄÐÐΪ¡£

ÒÔÉϾÍÊÇsqlÖÐlpadº¯ÊýÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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