I need a query that looks like this for mysql:
我需要一个mysql的查询:
SELECT * FROM table_name
WHERE column_name like %value%
IN (SELECT * FROM table_name WHERE column_name like %second_value%)
How can i do this?
我怎样才能做到这一点?
Thanks!
谢谢!
2 个解决方案
#1
3
As my understanding of your issue is correct, your query must be:
由于我对您的问题的理解是正确的,您的查询必须是:
SELECT * FROM table_name
WHERE column_name like '%value%' and column_name like '%second_value%'
#2
2
You cannot select multiple columns from the nested IN
query. You can only select one column.
您无法从嵌套的IN查询中选择多个列。您只能选择一列。
I assume, you want to select column_name
from the nested query.
我假设您要从嵌套查询中选择column_name。
SELECT * FROM table_name WHERE column_name like '%value%' IN
(SELECT column_name FROM table_name WHERE column_name like '%value%')
// ^^^^^^^^^^^
#1
3
As my understanding of your issue is correct, your query must be:
由于我对您的问题的理解是正确的,您的查询必须是:
SELECT * FROM table_name
WHERE column_name like '%value%' and column_name like '%second_value%'
#2
2
You cannot select multiple columns from the nested IN
query. You can only select one column.
您无法从嵌套的IN查询中选择多个列。您只能选择一列。
I assume, you want to select column_name
from the nested query.
我假设您要从嵌套查询中选择column_name。
SELECT * FROM table_name WHERE column_name like '%value%' IN
(SELECT column_name FROM table_name WHERE column_name like '%value%')
// ^^^^^^^^^^^