简体   繁体   English

MYSQL:WHERE NOT LIKE'%(SELECT column_name FROM table_name)%'

[英]MYSQL: WHERE NOT LIKE '%(SELECT column_name FROM table_name)%'

i try to find %column_name% from another table_name i see the result but he seems to ignore the %% 我试图从另一个table_name中找到%column_name%我看到了结果,但他似乎忽略了%%

Why it does not work for me? 为什么它对我不起作用?

SELECT column_name FROM table_name WHERE NOT LIKE '%(SELECT column_name FROM table_name)%'

thanks, Apologies if I do not act according to the rules, this is my first question. 谢谢,道歉,如果我不遵守规则,这是我的第一个问题。

Try this: 尝试这个:

SELECT column_name FROM table_name WHERE NOT LIKE (SELECT CONCAT('%', column_name, '%') FROM table_name)

You can't just include a query in a string, so put the wildcards next to the column name in a query and return that to the NOT LIKE. 您不能只在字符串中包含查询,因此在查询中将通配符放在列名旁边,并将其返回到NOT LIKE。

SELECT column_name
FROM table_name T
WHERE NOT EXISTS ( SELECT column_name from other_table O
                   WHERE O.column_name LIKE CONCAT('%',T.column_name,'%')
                 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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