请建议我如何使用加入这个situtation [英] Please suggest me how to use join in this situtation
本文介绍了请建议我如何使用加入这个situtation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好先生,
我有桌子叫
客户
Id名称地址
1 SUNIL X
2 Mahesh Y
3 Ajay Z
4 Krunal A
AddInfo
Id Telephone CustId( Foreign Key )
12 393939393 1
13 810241123 1
14 123232332 1
15 1232323 2
16 1232323 2
17 1232323 3
我想要一份清单那些在AddInfo表格中没有电话号码的客户。
O / p应该是
Id名称地址
1 SUNIL X
2 Mahesh Y
3 Ajay Z
谢谢,
问候SUNIL
解决方案
Hello Sunil,
您可以使用SQL INNER JOIN来检索期望的结果。
SELECT DISTINCT c.id ,c.name,c.address
FROM 客户 AS c
INNER JOIN addinfo AS a
< span class =code-keyword> ON a.custid = c.id
问候,
您好sunil,
试试这个... :)
< span class =code-keyword> select Customer.Name,Customer.Address from Customer inner join AddInfo Customer.Id = AddInfo.CustId
从客户
中选择
*
其中
Id在
(从AddInfo中选择CustID)
-------------------------------------------------
- 或
--------------------------------------- --------- -
选择
distinct CM。*
来自
Addinfo AI
内部加入
客户CM
关于AI.CustID = CM.Id
Hello sir,
I have table Called
Customer
Id Name Address
1 SUNIL X
2 Mahesh Y
3 Ajay Z
4 Krunal A
AddInfo
Id Telephone CustId(Foreign Key)
12 393939393 1
13 810241123 1
14 123232332 1
15 1232323 2
16 1232323 2
17 1232323 3
I want list of those customer whose Telephone No is present in AddInfo table.
O/p should be
Id Name Address
1 SUNIL X
2 Mahesh Y
3 Ajay Z
Thanks,
Regards SUNIL
解决方案
Hello Sunil,
You can use SQL INNER JOIN to retrieve the desired result.
SELECT DISTINCT c.id, c.name, c.address FROM customer AS c INNER JOIN addinfo AS a ON a.custid = c.id
Regards,
Hi sunil,
try this...:)
select Customer.Name,Customer.Address from Customer inner join AddInfo on Customer.Id=AddInfo.CustId
Select * from Customer where Id In (Select CustID from AddInfo) ------------------------------------------------- --OR ------------------------------------------------- Select distinct CM.* From Addinfo AI Inner Join Customer CM On AI.CustID = CM.Id
这篇关于请建议我如何使用加入这个situtation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文