I have a string of category IDs
that look like this 1;2;3;4;
.
Now I want to fetch all the posts that contain each of these variables in the category
column of the posts
table.
The category
column also have the content like this 1;2;3;
depending on what categories have been attached to the post.
How can I set up a PDO query
that checks if any of the value from the primary string is found within the category
column in the post table?
I am looking for something which would look like category LIKE = IN (2;3;4;)
, also it has to work with double/triple ... digits like this: 2;44;23;
.
Example:
- Post 1: 1;2;
- Post 2: 3;
- Post 3: 1;
I use the string 1;
to fetch from the post table, and the result I want back is Post 1
and Post 3
because they both contain 1;
.