954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

show only latest field for each ID

dear all

i have 2 tables, one is project table and another replies table.

"SELECT * FROM project, replies WHERE replies.member_id=$_SESSION[member_id]
AND project.project_id=replies.project_id ORDER BY project.project_id ";

the above code gives me all , but I need the latest updated replied in each project id
I tried

SELECT * FROM project INNER JOIN replies ON  project.project_id=replies.project_id 
 WHERE replies.member_id=$_SESSION[member_id] GROUP BY replies.project_id ORDER BY project.project_id ";

it gives me the unique project id however it does now show the latest trainer replies. I have a date column in database does it helps?

qwertpink
Newbie Poster
12 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 
select * from project p, replies r
where p.project_id=r.project_id
and
r.mydate = (select max(mydate) from replies rr where rr.project_id=p.project_id group by project_id)
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

Thank you smantscheff !
Thanks so much for your help!
(:

qwertpink
Newbie Poster
12 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: