9pixle
9pixle

Reputation: 556

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%'"); 

Upvotes: 0

Views: 620

Answers (1)

juergen d
juergen d

Reputation: 204924

select table_name
from information_schema.tables
where table_name LIKE '%plan_2%'
and table_name NOT LIKE '%temp%'

Upvotes: 6

Related Questions