uttam sharma
uttam sharma

Reputation: 5

How to perform join operation for following table?

I am a beginner programmer. Here are my table structures:

Database structure

I want to retrieve content and type field from 'post' table where userdId following the 'following' field. I am trying this SQL Join for retrive post of followers.

SELECT userId,following, userId,postId,content,file,type
FROM follow, post
WHERE userId = '5a37589e4ff8b'

Upvotes: 0

Views: 49

Answers (1)

Nigel Ren
Nigel Ren

Reputation: 57131

You should use the JOIN syntax

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 = '5a37589e4ff8b'

Upvotes: 2

Related Questions