更新时间:2023-12-02 10:21:58
这是一个简单的JOIN
.
尝试一下:
select c.comment_id,
c.comment_content,
u.user_id,
u.user_name,
c.post_id
from comments c
join users u on u.user_id = c.user_id;
如果您还需要发件表中的列,请加入它:
If you need columns from posts table too, join it:
select c.comment_id,
c.comment_content,
u.user_id,
u.user_name,
p.post_id,
p.post_content
from comments c
join users u on u.user_id = c.user_id
join posts p on c.post_id = p.post_id;