左外连接到生成的表?
我的方针完全错误吗? 我想对从 2 个表生成的查询进行左外连接,但我不断收到错误。我需要不同的方法吗?
t1:
ID, Surname,Firstname
t2:
ID,JobNo,Confirmed
我有以下查询:
SELECT JobNo AS N, StaffID AS P, Confirmed as C,
FirstName AS F,Surname AS S
FROM gigs_players, Players
WHERE t1.StaffID=t2.StaffID AND JobNo="2"
AND (`Confirmed` IS NULL OR Confirmed ='Y' )
ORDER BY Instrument,Surname
我想添加:
LEFT OUTER JOIN contacted (ON t1.StaffID=contact.ID AND t2.JobNo=contact.JobNo)"
我可以对从 2 个表生成的查询执行左外连接
吗?
Am I on completely the wrong tack ?
I want to do a left outer join to a query generated from 2 tables , but i keep getting errors. Do I need a different approach?
t1:
ID, Surname,Firstname
t2:
ID,JobNo,Confirmed
I have the following query:
SELECT JobNo AS N, StaffID AS P, Confirmed as C,
FirstName AS F,Surname AS S
FROM gigs_players, Players
WHERE t1.StaffID=t2.StaffID AND JobNo="2"
AND (`Confirmed` IS NULL OR Confirmed ='Y' )
ORDER BY Instrument,Surname
I want to add:
LEFT OUTER JOIN contacted (ON t1.StaffID=contact.ID AND t2.JobNo=contact.JobNo)"
Can I do a left outer join
to a query generated from 2 tables ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了在要添加的左外连接中使用
t1
和t2
,您需要将它们与第一个表连接,您不能直接在左外连接,如下所示:因此,根据表的结构,定义与其他表的
t1
和t2
的两个连接的条件。In order to use the
t1
andt2
in the left outer join that you want to add you need to join them with the first tables, you can't reference them directly in the left outer join you, Something like the following:So, based in your tables' structure, define the conditions of the two joins with
t1
andt2
with other tables.以下是子查询的左连接示例。这可能就是您正在寻找的。
Here is the an example of a left join to a sub query. This might be what you are looking for.