0
我編寫一個查詢從3個表中獲取值獲取多個值,但是這是返回多個值,所以任何一個可以告訴我哪裏錯了從查詢
select c.CompanyName,cd.FedTaxID,cd.EmailAddress,cd.PhoneNumber
from tblcustomerdetail cd,tblcustomer c
where c.FedTaxID in (
select FedTaxID
from tblcustomer
where CustomerID in (
select LOginID
from tbluserlogindetail
where UserName like "pa%" and RoleTypeID='20'
)
)
and cd.FedTaxID in (
select FedTaxID
from tblcustomer
where CustomerID in (
select LOginID
from tbluserlogindetail
where UserName like "pa%" and RoleTypeID='20'
)
);
我的關係在這裏
我3個表是`tbluserlogindetails,tblcustomerdetails和tblCustomer」
1) Initially i will get `Login ID` from `tblUserLoginDetail ` based on the `user name`.
2) Next based on `LoginID` i will get `FedTaxID` from tblcustomerDetail`
3) Next based on 'FedTaxID' i will get the the required details from `tblcustomer'
好像過度使用子查詢。 – Jacob
顯示一些數據,tblcustomerdetail和tblcustomer兩個表之間是否有任何關係? – Kangkan