I have an issue with NOT LIKE statement. I have two sql tables setup as tag map. First table finds tag_id according to the search name and second finds resource_id based on tag_id found. When I run a NOT LIKE statement below, I receive the result: resource_id = 1.
Tag map tables
tag_id name
1 meat
2 vegetarian
resource_id tag_id
1 1
1 2
Query
SELECT
f.id, f.food_name, tm.resource_id, tm.tag_id, t.name
FROM
tag as t, tagmap as tm JOIN item as f ON
(
f.id = tm.resource_id AND tm.tag_id IN
(
SELECT
t.tag_id
FROM
tag as t
WHERE
t.name NOT LIKE '%meat%'
)
)
GROUP by f.id
All I need this query to do is, if it finds a resource_id with tag name “meat” I don’t want it to return this resource_id.
If my explanation is not clear please let me know.
Then you must search for:
or with a
join:You look for
resource_idwith name “meat” and exclude thesenot inin your select.This might correspond to your query, but I’m not really sure: