Categories
PHP

how to retrieve post from following in these given tables

Here is the database table structure I am using:

enter image description here

I want to perform a JOIN operation in MySQL to retrieve post for following users.

Currently I am using this query but this don’t gives me the desired results.

SELECT f.userId, f.following, p.postId, p.content, p.file, p.type
FROM follow f JOIN post p ON p.userId = f.userId
WHERE f.userId =  '$userId' LIMIT 0 , 30

Thanks.

Leave a comment