I have two tables..
1st Table: post
|post_id | post_data |
..........................
| 1 | any data |
| 2 | any data |
| 3 | any data |
2nd Table: post_likes
|like_id | post_id | by_user |
....................................
| 1 | 1 | 3 |
| 2 | 3 | 3 |
when ever a user like any post data is stored in posts_likes table.. i want to show that posts (from both tables once) that are not liked by user 3..
i am using this query
SELECT *
FROM post, post_likes
WHERE post.post_id != post_likes.post_id
AND by_user=3
it showing me these results..
post_id post_data like_id post_id by_user
1 my data 2 3 3
2 my data 1 1 3
2 my data 2 3 3
3 my data 1 1 3
But it should show the result of post_id=2 only (because post_id 1 and 3 are liked by user)
what will be the correct query by which i can get those posts that are not liked by user 3