Answer the question
In order to leave comments, you need to log in
How to get matched values?
I have entries:
car_id user_id created_at count
26 1 - -
27 1 - -
27 8 - -
I need to get users who have the same car_id knowing only user_id. How can I do that?
because I write user_id IN (1, 8) displays 3 records.
Answer the question
In order to leave comments, you need to log in
SELECT
*
FROM tablename t
JOIN tablename t2 ON t2.user_id IN (1, 8) AND t2.user_id != t.user_id AND t2.car_id = t.car_id
WHERE t.user_id IN (1, 8)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question