is this possible?
update table set number2 = number where number != "" and set number, number2 = $number where number="";
or do i need to do
update table set number2 = number where number != "";
update table set number = $number, number2 = number where number = "";
I would just do them as two “separate” statements and not worry about trying to find a clever solution (which is rarely clever IMNSHO).
You’ll see I quoted the word “separate” above since any decent DBMS will provide transactional support which will make the two of those statements into one, in terms of atomicity (the A in ACID).
In other words, something like:
This will almost invariably be faster (assuming
numberis indexed) than a clever solution using per-row functions likeCASE,IFand so on, since two very fast passes is better than one slow pass 🙂