[SOLVED] How to eliminate potential rows on table joins.
Posted: Tue Sep 11, 2007 3:24 am
In table A I have several unique rows then table B has several entries for each row on table A. When I join the tables I want only the latest entry from table B to be joined to table A on their unique IDs.
The latest entry can be determined by a unix timestamp on table A but my queries seems to be failing. I'm trying to use this at the moment but it selecting all rows from table B on the join, not just the one with the highest unix timestamp.
But this joins to every row in table B not just the row with the highest timestamp.
The latest entry can be determined by a unix timestamp on table A but my queries seems to be failing. I'm trying to use this at the moment but it selecting all rows from table B on the join, not just the one with the highest unix timestamp.
Code: Select all
select max(b.timestamp), a.*
from tableA as a, tableB as b
where a.id = b.backupID
and a.customer != 'APT'
and b.apt = 'n'
group by b.timestamp