多个 MySQL 嵌套选择
你好,我想知道是否有人可以帮忙,我完全精神障碍。
我有一个完美运行的 select 语句,但是我现在想对照另一个表检查结果(名字和姓氏),以了解有关它们的更多详细信息。我一辈子都不知道该怎么做。
SELECT `FirstName` , `Surname` , MobilePhone
FROM users
WHERE NOT
EXISTS (
SELECT PhoneNumber
FROM Orangedata
WHERE users.MobilePhone = orangedata.`PhoneNumber`
)
此选择返回我想要运行另一个选择的记录列表(姓名和手机)。
结果看起来像
FirstName Surname Mobile
我想运行我的下一个选择,它说
Select *
from Table 3
WHERE FirstName = FirstName from previous select AND WHERE Surname = Surname from previous select.
我正在寻找的总体结果是
为在表 Orangedata 中没有任何记录的用户提供所有详细信息(来自表 3)
它实际上是三个嵌套选择(我想)但我就是想不出来
Hi there I wonder if someone could help, I am having a complete mental block.
I have this select statment that works perfectly, however I now want to check the results (FirstName and Surname) against another table to find out more details about them. I can't for the life of me figure how to do that.
SELECT `FirstName` , `Surname` , MobilePhone
FROM users
WHERE NOT
EXISTS (
SELECT PhoneNumber
FROM Orangedata
WHERE users.MobilePhone = orangedata.`PhoneNumber`
)
This select returns me a list of records (Name and Mobiles) that I want to run another select with.
The Result looks like
FirstName Surname Mobile
I want to run my next Select that says
Select *
from Table 3
WHERE FirstName = FirstName from previous select AND WHERE Surname = Surname from previous select.
The overall result I am looking for is
Give me all the details (from Table 3) for a user that does not have any record in table Orangedata
Its effectively three nested selects (I think) and I just can't figure it out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者像这样的东西
Or something like this