Unanswered: how to write this select statement in sql?
I have 3 tables tbl1, tbl2, tbl3
Tbl1 contains column: fund, fund name, group (fund is PK)
Tbl2 contains column: fund, deal, deal name (fund and deal is PK, fund is FK of tbl1)
Tbl3 contains column: id, fund, deal, price, profit. (id is PK, but fund and deal are fk of the tbl2)
Now, I have certain criteria value for fund name, deal name.
I need based on these value to select the fund, deal name, price, profit. Anybody know how to write the query?
I have written the one as following, but it’s not correct:
Select tbl3.fund, tbl3.[deal name], price, profit from tbl2, tbl3
where tbl2.fund = tbl3. fund and tbl3.deal = tbl2.deal and
(select fund, deal from tbl1 and tbl2 where tbl1.fund = tbl2.fund and [fund name] = 'XXX" and [deal name] = 'YYY")
Anybody know how to write this query? Thanks a lot for the help
select tbl1.fund, tbl2.dealname, tbl3.price, tbl3.profit
from tbl1, tbl2, tbl3
where tbl1.fund = tbl2.fund
and tbl1.fund = tbl3.fund
and tbl2.deal = tbl3.deal
and tbl1.fundname = "xxx"
and tbl2.dealname = "yyy"