Learn about SQL joins .
SELECT * FROM tbl1 JOIN tbl2 USING (entry_id) WHERE cat_id IN (233,234);
Take a look at sqlfiddle .
UPDATE
To select all entries in both categories, you can group the connection results and select only those groups that contain both categories:
SELECT tbl1.* FROM tbl1 JOIN tbl2 USING (entry_id) WHERE cat_id IN (233,234) GROUP BY entry_id HAVING COUNT(DISTINCT cat_id) = 2
Take a look at sqlfiddle .
Obviously, COUNT(DISTINCT cat_id)
can be replaced with (much less expensive) COUNT(*)
if (entry_id, cat_id)
is unique in tbl2
.
source share