简单的SQL查询分类

时间:2014-02-21 18:30:48

标签: mysql data-extraction

http://i61.tinypic.com/21dexc6.png

我想在胜利专栏中填入胜利或失败的胜利,胜利被定义为1-3完成和失去其他一切。

2 个答案:

答案 0 :(得分:2)

UPDATE table set win = 'lose' WHERE place NOT in (1,2,3);
UPDATE table set win = 'win' WHERE place in (1,2,3);

OR或一个小CASE声明

UPDATE table set win =  CASE WHEN place IN (1,2,3) THEN 'win' 
                             WHEN place NOT IN (1,2,3) THEN 'lose' 
                        END ;

答案 1 :(得分:2)

这是您需要的查询吗?

update mytable set win = 'WIN' where place <= 3;
update mytable set win = 'LOSS' where place > 3;