Skip to content
Advertisement

Update Timestamp field with the oldest record of fields within the row or those in a linked table

One table looks like this:

TABLE A Nullables
a_id not nullable
create_timestamp not nullable
edit_timestamp nullable
closed_timestamp nullable
last_mod_timestamp not nullable

The other one like this:

TABLE B Nullables
b_id not nullable
table_a_fk not nullable
create_timestamp not nullable

How would I set last_mod_timestamp to the oldest value of either (a.create_timestamp, a.edit_timestamp, a.closed_timestamp) or b.create_timestamp where b.table_a_fk = a.id?

Datatypes are all Timestamp.

Thanks in advance!

Advertisement

Answer

Try this:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement