Tables:
Query:
I want it to return rows 1,2,3 from items, because those 3 contain "cow" in either the name or tag.
However, it is returning 1,2,2,3 from items, because item 2 has 2 tags assigned to it.
Solution? The tables can be altered if need be.
Code:
[b]items[/b]
itemid | name
1 | Cow
2 | Small Cow
3 | Sheep
4 | House
[b]tags[/b]
itemid | tag
2 | Milk
2 | Grass
3 | Cow
Query:
SELECT * FROM items LEFT JOIN tags ON items.itemid = tags.itemid WHERE item.name LIKE '%cow%' OR tags.tag LIKE '%cow%'
I want it to return rows 1,2,3 from items, because those 3 contain "cow" in either the name or tag.
However, it is returning 1,2,2,3 from items, because item 2 has 2 tags assigned to it.
Solution? The tables can be altered if need be.