Bottom line, I want to be able to search for items by tag and tag combinations (plus and minus). I played with subqueries and considered CTE functionality, but the first is labor intensive and the second doesn't work because the tag subquery changes by result. I think I can cheat by doing simple string search instead like so:
SELECT *, CONCAT(',',(SELECT GROUP_CONCAT(tag_id) FROM item_tags WHERE item_id = id),',') as tags FROM items
WHERE
tags LIKE '%,97,%'
AND tags LIKE '%,30,%'
AND tags NOT LIKE '%,7,%'
The extra commas cover situations like how 7 would normally match 17, 107, etc (with the commas, I can search for just "7".
Anyway, it's saying "unknown column 'tags' in where clause" which I guess means you can't search a created value using LIKE? But I can't find a way to do a string search of created values either.
I could use some help finding either a way to do substring search of my "tags" value OR a more sophisticated way of solving my core issue. I could probably make it work by replacing each "LIKE" line with a repeated subquery, but that seems wildly inefficient.