请告诉我如何提出请求。我需要从2个表中为[userid]和[fuserid]字段选择相同的值。
SELECT a.userid, b.fuserid FROM users, fusers WHERE a.userid=457281 AND b.fuserid=457281
- 空白字段[userid] [fuserid],虽然用户在表格中有2个值,而不是YET可用值
SELECT a.userid, b.fuserid FROM users RIGHT JOIN fusers ON a.userid=457281 AND b.fuserid=457281
也会产生空字段[userid] [fuserid]
SELECT a.userid, b.fuserid FROM users LEFT JOIN fusers ON a.userid=457281 AND b.fuserid=457281
- 发行垃圾邮箱,例如
[userid][fuserid]
[457281][NULL]
[457281][NULL]
[391419][NULL]
- 一个不必要的额外字段
SELECT a.userid, b.fuserid FROM users JOIN fusers ON a.userid=457281 AND b.fuserid=457281
- 空白字段
(SELECT a.userid FROM users WHERE a.userid=457281) UNION (SELECT b.fuserid FROM fusers WHERE b.fuserid=457281)
- 返回值为457281的单个列,在本例中为[userid]
但我需要选择2个表相同的输入字段userid和fuserid显示在不同的列中,所以:
[457281][457281] or
[NULL][457281] or
[457281][NULL]
答案 0 :(得分:0)
很难弄清楚你想要什么,但根据你想要的结果,这是我的猜测。
[457281] [457281]或 [NULL] [457281]或 [457281] [NULL]
Select a.userid, b.fuserid
From users u
Full Outer Join fusers f on f.fuserid = u.userid
Where f.fuserid = 457281 or u.userid = 457281