我有两个表:
用户[id,用户名]
评论[标题、内容、postid、userid]
我的后端是nodejs... 我怎样才能查询所有评论而不是得到id,而是得到结果中的用户名?
Select * from comments where postid=1
在这种情况下,我将在结果中获取用户 ID 我需要相对数据库吗?
最佳答案
使用连接
select username,title,content from user u join comments c on u.id=c.userid
关于mysql - Sql 相对数据库用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54494575/