I have two tables in mysql table1 and table2
table1 have the following fields
Field Type
intProjectId int(11)
intSourceId int(11)
intClientId int(11)
varProject varchar(200)
fltAmount float
varAmountType varchar(50)
dtStart date
dtEnd date
And table 2 have the following fields
Field Type
intPercentageId int(11)
intProjectId int(11)
floatPaymentpercentage float
ddDate datetime
join two table with common project id.If table2 has no records with the particular project id it can joined as null..
Table 1 has project data Table 2 has its percentage of complettion. (Each project has more than one records. ) Project Id -- common field
Iused the following query
SELECT * FROM table1 LEFT OUTER JOIN table2 ON table1.intProjectId = table2.intProjectId
GROUP BY table1.varProject ORDER BY table2.intPercentageId DESC
Here i get the output as percentage table returns the first record for each project. I need the last inserted record for the table 2.
table1 ==> project id 5 In table 2 has 3 records for project Id 5. I want to ge the last record from the table2. Now it returns the first record from table 2
How to change the query. Please help me to fix this.