mysql join Two tables to get records
- by Saranya
Hai guys,
I have two tables Incharge and property. My property table has three fields 1stIncharge,2ndIncharge and 3rdIncharge. InchargeId is set as foreign key for all the above fields in the property table..
How to write a select statement that joins both the table.. I ve tried a bit but no result
select P.Id,P.Name,P.1stIncharge,P.2ndIncharge,P.3rdIncharge,I.Id from
Property as P join Incharge as I where (\\How to give condition here \\)
Guys 3 fields P.1stIncharge, P.2ndIncharge, P.3rdIncharge has foreign key I.Id
Edit:
select P.Id,P.Name,P.1stIncharge,P.2ndIncharge,P.3rdIncharge,I1.Id from
Property as P
inner join Incharge as I1 on I1.Id=P.1stIncharge
inner join Incharge as I2 on I2.Id=P.2ndIncharge
inner join Incharge as I3 on I3.Id=P.3rdIncharge
and this query working