我注意到我的SQL查询中有错误,但我不确定我做错了什么:
SELECT blog_posts.postid,
blog_posts.posttitle,
blog_posts.postdesc,
blog_posts.postdate
FROM blog_posts
INNER JOIN members_posts
ON members_posts.memberid = blog_posts.postid
WHERE members_posts.memberid = '1'
在上面我试图只选择属于memberID ='1'的帖子。什么都没有显示?
答案 0 :(得分:2)
这是您的查询:
SELECT bp.postID, bp.postTitle, bp.postDesc, bp.postDate
FROM blog_posts bp INNER JOIN
members_posts mp
ON mp.memberID = bp.postID
-----------^ ------------^ That seems unlikely
WHERE mp.memberID = '1';
使用正确的列:
SELECT bp.postID, bp.postTitle, bp.postDesc, bp.postDate
FROM blog_posts bp INNER JOIN
members_posts mp
ON mp.postId = bp.postID
WHERE mp.memberID = 1;
另外: