mardi 29 mars 2016

MYSQL INSERT based on values from 3 columns

I have a mysql database and I would like to do an SELECT/INSERT based on the conditions of three different numeric fields: (HI, OT and WC).

I want to INSERT into a field called AT the value of the following condition:

HI if HI > OT
else
WC if WC < OT
else 
OT

Something like this, but I cannot seem to get it correct:

INSERT INTO variations (AT)
SELECT

HI if HI > OT
else
WC if WC < OT
else
OT,
FROM archive;

Aucun commentaire:

Enregistrer un commentaire