mysqlÖÐ%ÊÇʲôÒâ˼
mysql ÖеİٷֺŠ% ÊÇÒ»¸öͨÅä·û£¬¿ÉÆ¥Åäí§Òâ×Ö·ûÐòÁС£Ëü¿ÉÓÃÓÚ£º1. ×Ö·û´®Æ¥Å䣨È磺like ‘%string%’); 2. ¹æÄ£ÅÌÎÊ£¨È磺between ‘%start%’ and ‘%end%’); 3. ÕýÔò±í´ïʽƥÅ䣨È磺regexp ‘%.*%’); ×¢ÖØ£º% Æ¥Åäí§Òâ×Ö·ûÐòÁУ¬µ«²»¿ÉÆ¥Åä¿Õ×Ö·û´®£»²»¿É·ºÆðÔÚͨÅä·û±í´ïʽµÄ¿ªÍ·»ò×îºó£»ÒªÆ¥ÅäÏÖʵµÄ°Ù·ÖºÅ£¬ÐèʹÓÃתÒå×Ö·û \¡£
MySQL Öеİٷֺţ¨%£©
MySQL Öеİٷֺţ¨%£©ÊÇÒ»¸öͨÅä·û£¬ÓÃÓÚÆ¥Åäí§Òâ×Ö·ûÐòÁС£Ëü¿ÉÒÔÔÚÒÔϳ¡¾°ÖÐʹÓãº
1. ×Ö·û´®Æ¥Åä
ÔÚ LIKE ×Ó¾äÖУ¬% ¿ÉÓÃÓÚÆ¥Åäí§Òâ×Ö·ûÐòÁУº
SELECT * FROM table_name WHERE column_name LIKE '%string%';
µÇ¼ºó¸´ÖÆ
Õ⽫ƥÅä°üÀ¨ “string” ×Ö·û´®µÄÈκμͼ¡£
2. ¹æÄ£ÅÌÎÊ
ÔÚ BETWEEN ×Ó¾äÖУ¬% ¿ÉÓÃÓÚÖ¸¶¨¹æÄ£µÄ×ó½çÏß»òÓÒ½çÏߣº
SELECT * FROM table_name WHERE column_name BETWEEN '%start%' AND '%end%';
µÇ¼ºó¸´ÖÆ
Õ⽫ƥÅä column_name Öµ½éÓÚ “start” ºÍ “end” Ö®¼äµÄ¼Í¼£¨°üÀ¨ “start” ºÍ “end” ×Ô¼º£©¡£
3. ÕýÔò±í´ïʽ
ÔÚ REGEXP ×Ó¾äÖУ¬% ¿ÉÓÃ×÷ͨÅä·ûÆ¥Åäí§ÒâÒ»¸ö×Ö·û£º
SELECT * FROM table_name WHERE column_name REGEXP '%.*%';
µÇ¼ºó¸´ÖÆ
Õ⽫ƥÅä°üÀ¨ÈκÎ×Ö·ûÐòÁеļͼ¡£
×¢ÖØÊÂÏ
% Æ¥Åäí§Òâ×Ö·ûÐòÁУ¬µ«²»¿ÉÆ¥Åä¿Õ×Ö·û´®¡£
% ²»¿É·ºÆðÔÚͨÅä·û±í´ïʽµÄ¿ªÍ·»ò×îºó¡£
ҪƥÅäÏÖʵµÄ°Ù·ÖºÅ£¬ÐèҪʹÓÃתÒå×Ö·û \£¬Èç \%¡£
ÒÔÉϾÍÊÇmysqlÖÐ%ÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡