Reputation: 23025
Please have a look at the below diagram.
Here, I need to retrieve the Investment_Type
of the Portfolio
using the idClient
. Investment_Type
is a String in Investment_Type
table.
Unfortunately, this database join is too complex for me :( . How can I achieve this task?
PS:
In simple terms, what I need to do is; I need to get the list of Clients
and see what are their Portfolios
and the portfolio_Type
of their each portfolio.
Upvotes: 0
Views: 181
Reputation: 944
SELECT Investment_Type
FROM Investment_Type
WHERE idInvestment_Type IN (
SELECT idInvestment_Type
FROM Portfolio
WHERE idPortfolio IN (
SELECT idPortfolio
FROM Client_Portfolio
WHERE idClient IN ( SELECT idClient FROM Client)
)
)
Upvotes: 2
Reputation: 174
Try the below mentioned Query:
SELECT IT.Investment_Type
FROM
Client_portFolio CF
LEFT JOIN portfolio P ON (CF.idPorFolio = P.idPorFolio)
LEFT JOIN investment_type IT ON(P.idInvestmentType =IT.idInvestmentType)
WHERE CF.idClient = <ClientId>
Upvotes: 2