sqlÖÐlikeÔõôд²»¼´ÊÇ
ÔÚ sql ÖУ¬Ê¹Óà not like ²Ù×÷·û¿ÉÒÔÅÌÎʲ»¼´ÊÇÌض¨Ä£Ê½µÄ×Ö·û´®¡£Óï·¨£ºselect * from table_name where column_name not like ‘%pattern%’; ÆäÖÐ %pattern% ÊÇҪƥÅäµÄģʽ£¬% ´ú±íͨÅä·û¡£
ÔõÑùÔÚ SQL ÖÐʹÓà LIKE ÅÌÎʲ»¼´ÊÇ
ÔÚ SQL ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà LIKE ²Ù×÷·ûÀ´Æ¥Åä°üÀ¨Ìض¨Ä£Ê½µÄ×Ö·û´®¡£ÈôÊÇÎÒÃÇÒªÅÌÎʲ»¼´ÊÇÌض¨Ä£Ê½µÄ×Ö·û´®£¬¿ÉÒÔʹÓà NOT LIKE ²Ù×÷·û¡£
Óï·¨£º
SELECT * FROM table_name WHERE column_name NOT LIKE '%pattern%';
µÇ¼ºó¸´ÖÆ
ÆäÖУº
table_name ÊÇÒªÅÌÎʵıíÃû¡£
column_name ÊÇҪƥÅäģʽµÄÁÐÃû¡£
%pattern% ÊÇҪƥÅäµÄģʽ£¬ÆäÖÐ % ´ú±íͨÅä·û£¬Æ¥Åäí§ÒâÊýÄ¿µÄ×Ö·û¡£
ÀýÈ磬ÎÒÃÇÒª´Ó customers ±íÖÐÅÌÎÊÐÕÃû²»°üÀ¨ “John” µÄËùÓпͻ§£º
SELECT * FROM customers WHERE name NOT LIKE '%John%';
µÇ¼ºó¸´ÖÆ
Õâ¸öÅÌÎʽ«·µ»ØËùÓÐÐÕÃûÖв»°üÀ¨ “John” µÄ¿Í»§¡£
×¢ÖØ£º
ÈôÊÇҪƥÅä׼ȷµÄ×Ö·û´®¶ø²»Ê¹ÓÃͨÅä·û£¬ÇëʹÓõȺţ¨=£©²Ù×÷·û¡£
ÈôÊÇҪƥÅä²»ÒÔÌض¨Ä£Ê½¿ªÍ·µÄ×Ö·û´®£¬ÇëʹÓà NOT LIKE ‘%pattern’¡£
ÈôÊÇҪƥÅä²»ÒÔÌض¨Ä£Ê½×îºóµÄ×Ö·û´®£¬ÇëʹÓà NOT LIKE ‘pattern%’¡£
ÒÔÉϾÍÊÇsqlÖÐlikeÔõôд²»¼´ÊǵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡