I have two tables : request and location
Sample data for request
request id | requestor | locations
1 | ankur | 2,5
2 | akshay | 1
3 | avneet | 3,4
4 | priya | 4
Sample data for locations
loc_id | loc_name |
1 | gondor
2 | rohan
3 | mordor
4 | bree
5 | shire
I'd like to find the request_id for a particular location. If I do this with location_id, I am getting correct results.
select request_id from request where locations like "%,3%" or locations like "%3,%";
This query gives me the requests raised for location id = 3
How can I achieve this for loc_name instead? Replacing the digit in the "like" part of the query with
select loc_id from locations where loc_name = "mordor"
Any help with this would be very helpful. Thanks.