Have 2 table table a and table b,
table A - id (primary key)
table B - aId(foreign key), userId, date
ex :
table A
|id|
|--|
|1|
|2|
|3|
table B
|aId (foreign key)|userId|
|--|--|
|1|1|
|1|2|
|2|1|
|3|3|
need to fetch id which contains both 1 and 2 userId
tried by below SQL with in but returns either but not both
SELECT ta.id
FROM tableA ta
JOIN tableB tb ON ta.id = tb.taId
WHERE tb.userId in (1,2);