2012-03-22 21 views
1

我有數據庫,在一個表中我需要改變列的值,由於混合另一位開發者我有名爲credits的表格和名爲credit_type的列。mySQL - 如何切換列值 - '短'到'長'和'長'爲'短'

credit_type有2個值longshort

如何將long的所有值替換爲short以及所有值爲short的值的值爲long

回答

3
update credits set credit_type = 'interim' where credit_type = 'long'; 
update credits set credit_type = 'long' where credit_type = 'short'; 
update credits set credit_type = 'short' where credit_type = 'interim'; 

將它全部包裝在交易中以獲得完全可靠性。