I have this query
SELECT *
FROM `posts`
WHERE `language` IN ( SELECT `possible_languages` FROM `users` WHERE user_id = ? );
In the table posts
: languages can be either en
or ar
In the table users
: possible_languages
can be either 'en'
, 'ar'
or 'en','ar'
When the selected value is 'en','ar'
the query doesn't work
I want it to be able to select Posts that are either en
or ar
IN ('en','ar')
You cannot use
in
with such lists. You can do this withexists
:This will be more efficient if you have an index on
users(user_id, possible_languages)
.