I hope someone can help. I have a table that has serveral records with
the same name but unique datestamps. I need to show only the records
with the latest datestamp associated with them. I am enclosing the sql
that I am working with in hopes that someone can see the problem that I
can't. I crashes at the GROUP BY line.
$sql = "
SELECT
P1.siname, P1.imin, P1.siti, P1.sito, P1.sireason, P1.id, P1.date,
P2.siname, MAX(P2.id) AS latest_time
FROM $table_name AS P1
INNER JOIN $table_name AS P2
GROUP BY P2.siname AS P3
ON P1.id = P3.latest_time
WHERE P1.imin=0
";
Any help will be appreciated.
Thanx,
Hank Schassen, ACI
CAD Manager
Aria/Jackson Architects
Tel: 206.323.8800
Fax: 206.323.8518
www.araijackson.com
| Thread |
|---|
| • INNER JOIN problem | hschassen | 3 Jan |