i have two tables:
users{user_id, username, picture}
likes{id, user_id, image_id}
the query im trying to do is:
select username, picture
from user and from likes
where user_id=user_id
and image_id=4
but i dnt know how to connect them, thanks
i have two tables:
users{user_id, username, picture}
likes{id, user_id, image_id}
the query im trying to do is:
select username, picture
from user and from likes
where user_id=user_id
and image_id=4
but i dnt know how to connect them, thanks
The key is to use an INNER JOIN between the two tables.
SELECT u.username, u.picture
FROM user u
INNER JOIN likes l
ON u.user_id = l.user_id
WHERE l.image_id = 4