Hello I have a table with 4 columns (ID, COL1, COL2, COL3) where (COL1 COL2 COL3) is default "0" , i want to make an update with php in the following way.
If COL1=0 make the updade in COL1
If COL1 is not=0 then go to COL2 and chek if it 0, and then update it.
So if the first column has anything else then "0" update the nex column.
Until ow i have something like this
but is not working ...i don`t know why
If COL1=0 make the updade in COL1
If COL1 is not=0 then go to COL2 and chek if it 0, and then update it.
So if the first column has anything else then "0" update the nex column.
Until ow i have something like this
Code:
mysql_query("UPDATE table SET
COL1 = CASE WHEN COL1 = '0' then 'something' else COL1 end where ID = '$id_example',
COL2 = CASE WHEN COL2 = '0' then 'something' else COL2 end where ID = '$id_example'
COL3 = CASE WHEN COL3 = '0' then 'something' else COL3 end where ID = '$id_example'");
Comment