简体   繁体   中英

SQL LIKE and NOT LIKE in same query

I have 100 tables. Some of the tables contain table name as 'plan_2' and some of them 'temp'.

So how can I select tables only 'plan_2' not containing 'temp'.

My query not working.

$result=mysql_query("SHOW TABLES LIKE 'plan_2%' AND TABLES  NOT LIKE '%temp%'"); 
select table_name
from information_schema.tables
where table_name LIKE '%plan_2%'
and table_name NOT LIKE '%temp%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM