How can I use an string input as 1,2,3,4
taken from a SELECT
to put in on an IN
condition?
I mean, having this output from this:
SELECT id_list
FROM ids
where categories = 4;
id_list
is a string like 1,2,3,4
.
Now I want to use that string to put in inside a IN ()
:
SELECT category_name
FROM categories
WHERE categories IN (
SELECT id_list
FROM ids
where categories = 4
)
But this only outputs the result of the first value of the string, in this case, 1
.
I know it's not the best implementation, but I'm not the one who made the DB design and I need to make the query this way. This is just a simplified example.
Can someone tell me how con I archieve my goal? Thanks in advance!