Jump to content

Update query with CASE


ginerjm

Recommended Posts

Having a bit of a problem forming an update query using a CASE statement in it. Can successfully do when using a SELECT query but my syntax is wrong with all the attempts I've made to use UPDATE. Here is my working select query

 

$q = "select machine_seq,
CASE machine_seq
WHEN $prev_seq then $seq
WHEN $seq then $prev_seq
END AS new_machine_seq
from workout_routines
where user_id = '$userid' and routine_id = '$routine' and
machine_seq in ($prev_seq,$seq)";

 

Can someone alter this to an UPDATE query for me? I'm trying to swap two values of the column named 'machine-seq'.

Link to comment
https://forums.phpfreaks.com/topic/297494-update-query-with-case/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.