Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Union three tables and join with 4th table

Status
Not open for further replies.

powerbala

Programmer
Jul 7, 2004
2
US
Hi... I am totally new to database programming. I am sorry if my problem is already answered by somebody in somewhere. This is my question. I have 4 tables. Example:

Table 1: Property
Fields: ID(Primary), Address

Table 2: Rent
Fields: [Pro ID](Forign), Date, Desc, Amount

Table 3: Income
Fields: [Pro ID](Forign), Date, Desc, Amount

Table 4: Expense
Fields: [Pro ID](Forign), Date, Desc, Amount


I want to Union table 2,3,4 and get Address field from table 1. So my final SELECT statement should be like this

Address, Date, Desc, Amount.

Anybody has solution for this please......

I thank you very much

 
Hey.. Never mind..! I found the solution.

SELECT * FROM (SELECT * FROM t2 UNION ALL SELECT * FROM t3 UNION ALL SELECT * t4) t5,t1 WHERE t1.ID = t5.[Pro ID]

Thats all.

Thank you very much..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top