I've built this SQL Query that should place the highest date value inside field_result but it isn't working as intended.
SELECT field_one, field_two, IF(((field_one IS NOT NULL AND field_one <> '') AND (field_one > field_two)), unix_timestamp(field_one), unix_timestamp(field_two)) AS result FROM TableA
The condition is very simple.
field_onemust exist, and contain some sort of value.- If
field_one > field_twoshowfield_oneotherwise showfield_two
It produces the result
"field_one", "field_two", "field_result"
"1495681346","1500328106","1500328106"
"1500342725","1500328106","1500328106"
"1499922505","1500329807","1500329807"
"1500343148","1500328106","1500328106"
"1500329593","1500328106","1500328106"
For some reason on row 2 the value for field_result is not 1500342725 (this value is approx 14619 greater than 1500328106).
I think I've got the correct syntax, but I'm unsure because the result isn't what I'm expecting
Aucun commentaire:
Enregistrer un commentaire