Hi!

Graham Cossey wrote:

TableA
record_id
product_ref

TableB
timestamp
record_id
action

I want to create a SELECT that joins these 2 tables where the JOIN to
TableB only returns the most recent entry by timestamp.

For instance, to select all columns:

select * from TableA
join TableB on TableA.record_id = TableB.record_id
order by timestamp desc
limit 1

So you just join everything, then order by time in descening order and then just returning the first record = the newest record in the database. If you don't want all columns, then simply replace the star with the names of the columns you want.

I hope that this is what you wanted the query to do.. :)

Cheers,
Krister Karlström, Helsinki, Finland

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to