我需要mysql查询,它将:
IF (result=win){SELECT dobitak} else if (result=half_win) {SELECT dobitak/2} else if (half_lost) {SELECT stake/2} else{0};
FROM matches
WHERE id=$id但我不知道这样写查询的最佳解决方案是什么。
发布于 2014-04-21 01:34:38
select case when result ='win' then dobitak
when result = 'half_win' then dobitak/2
when result = 'half_lost' then stake/2
else 0
end as result
FROM matches
WHERE id=$id发布于 2014-04-21 01:34:18
我认为你可以用一个case语句做你想做的事情:
select (case when result = win then dobitak
when result = half_win then dobitak/2
when half_lost then stake / 2
else 0
end)
from matches
where id = $id;https://stackoverflow.com/questions/23189548
复制相似问题