MySQL Forums
Forum List  »  Newbie

MAX(column1,column2)
Posted by: Gavriel Fleischer
Date: July 25, 2005 12:33PM

Hi!

I need to do something like this:

CREATE table a (
id INT,
name VARCHAR(32),
last TIMESTAMP
);

CREATE table b (
id INT,
salary INT,
last TIMESTAMP
)

SELECT a.id, a.name, b.salary, MAX(a.last,b.last) AS last FROM a LEFT JOIN b ON a.id=b.id;

As you see I have different data about the same person in the two tables, but the two tables are updated in different time, and I need to know when was the last modification for a certain person (wheter it was in a or b)

(In my real problem I have actually more tables in a more complex join)

Is there any way to do this MAX(col1,col2,col3) thing?

Options: ReplyQuote


Subject
Written By
Posted
MAX(column1,column2)
July 25, 2005 12:33PM
July 25, 2005 12:59PM
July 25, 2005 02:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.