I need to create a MySQL query which searches for values, but I need the results to return which have the same content_id number (which is unknown until searched for).
Here's my table:
content_id item_id tag_id
1 4 2
1 4 3
1 4 4
1 4 5
2 5 7
2 5 8
3 6 8
3 6 9
And currently here's my query:
SELECT item_id FROM table WHERE tag_id IN (7,8)
This is returning:
Array
(
[0] => stdClass Object
(
[item_id] => 5
)
[1] => stdClass Object
(
[item_id] => 5
)
[2] => stdClass Object
(
[item_id] => 6
)
)
But I need it to return (because of content_id = 2 in this instance):
Array
(
[0] => stdClass Object
(
[item_id] => 5
)
)
I hope this makes sense..
andclause andgroup