All entity_id's with service_id's equal to 5 and 6.
(or all entities that have both service 5 and service 6)
In this case this is entity_id=1 (but not 2 and 3).
Is there a way to do this?
And how would I do it?
I've tried to search and read up on it, but frankly I have not found anything.
I have a strong feeling that this cannot be done, unless you go into code and have logic there.
I'd also gladly do it with temp table, but that too didnt inspire a solution from me.
The only way I thought of would be with GROUP_CONCAT, but that is cheesy and my mysql version doesent support it.
Thanks a lot
PS if for some reason you need sql for table and data:
I have table mapper:
CREATE TABLE mapper (
service_id integer NOT NULL,
entity_id integer NOT NULL
INSERT INTO mapper (service_id, entity_id) VALUES (5, 1);
INSERT INTO mapper (service_id, entity_id) VALUES (6, 1);
INSERT INTO mapper (service_id, entity_id) VALUES (5, 2);
INSERT INTO mapper (service_id, entity_id) VALUES (6, 3);
to view data:
FROM mapper AS m
ORDER BY m.entity_id
Hm, I do not know why the cynicism,
but I do know how to use joins and if nothing else I have ONE table here.
And unless you think I should use self join (which I dont think you are, but if you do please make a concrete suggestion) it makes no sense. Anyway self join dont make no sense either.