SELECT * FROM `image_appreciations`
WHERE `image_id` IN(SELECT `id` FROM `images` WHERE `user_id` = '1')
Is my current query, it returns zero results
SELECT `id` FROM `images` WHERE `user_id` = '1'
being the subquery returns around 8 id's which two of them are found in
SELECT * FROM `image_appreciations`
WHERE `image_id` IN(77,89)
And that works fine. But all together it fails. What am i doing wrong?
This could be done using JOIN
. Below is an example using the implicit short-hand syntax.
SELECT * FROM image_appreciations a, images i
WHERE a.image_id = i.id AND i.user_id = 1
A subquery like this "should" work, odd that's it not. Anyway, you can try using a JOIN
to solve this.
SELECT * FROM `image_appreciations`
JOIN `images` ON `image_id` = `id`
WHERE `images`.`user_id` = '1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With