连接给出两行而不是一行
我有这样的连接:
select first_name, last_name, photo_path, private_messages, mid_thumb,
bio_blurb, user_email
from users
left join member_photo on users.user_id = member_photo.photo_member_id
left join user_email_options on users.user_id = user_email_options.email_user_id
where user_id = 2
出于某种原因,它给出了两行,而不是我期望的用户信息的 1 行。我有什么明显遗漏的东西吗?我以前做过很多左连接,但似乎从未遇到过这种情况。为什么我会在结果集中得到 2 项?
例如,页面上发生的情况如下:
http://www.comehike.com /community/hiker_public_profile.php?community_member_id=2
请参阅 - 两条记录。
I have this join:
select first_name, last_name, photo_path, private_messages, mid_thumb,
bio_blurb, user_email
from users
left join member_photo on users.user_id = member_photo.photo_member_id
left join user_email_options on users.user_id = user_email_options.email_user_id
where user_id = 2
For some reason, it gives two rows instead of 1 row that I expected with the users information. Is there anything obvious that I am missing? I have done a bunch of left joins before and never seem to have encountered this. Why would I get 2 items in the result set?
Here is what happens on the page for example:
http://www.comehike.com/community/hiker_public_profile.php?community_member_id=2
See - two records.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来
member_photo
或user_email_options
有不止一行对应于 user_id 2Sounds like
member_photo
oruser_email_options
has more than one row corresponding to user_id 2