table_a:
id label
-----------------
1 l1
2 l2
3 l3
table_b:
table_a_id table_c_id
---------------------------
1 1
1 3
1 4
2 2
2 4
3 1
3 4
3 8
How can I select all records from table_a that are associated with both table_c_id 1 AND 4? Is it possible to have n table_c_id conditions?
The following is wrong, but it illustrates what is needed.
SELECT table_a.*
FROM table_a
JOIN table_b ON ( table_a_id = id
AND table_c_id = 1
AND table_c_id = 4 )
Use an IN clause.
EDIT: Updated the query based on the comments posted.