[英]MYSQL: LIKE with Except Condition
I need some help. 我需要协助。 I want to show database that has name
"sample"
but except "sample"
with "fallback"
word. 我想说明,有名称数据库
"sample"
,但除了"sample"
与"fallback"
字。
Database Name
sample_1
2_sample
sample_fallback
samsple_2
s_sample
fallback_sample
I just want to get: 我只想得到:
sample_1
2_sample
samsple_2
s_sample
What should I add from this query? 我应该从该查询中添加什么?
"SHOW DATABASES LIKE '%sample%';"
You're going to need to query the information_schema
directly to get this list. 您将需要直接查询
information_schema
以获得此列表。
select schema_name
from information_schema.schemata
where schema_name like '%sample%'
and schema_name not like '%fallback%'
SHOW DATABASES
isn't flexible enough. SHOW DATABASES
不够灵活。
SHOW DATABASES LIKE '%sample%' AND NOT LIKE '%fallback%';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.