我真的很努力地找到這個問題的答案。我想寫一個if或case語句來改變另一列的值。如果「檢查」列是0,那麼列'點'也應該爲0。SQL中的IF/CASE語句
SELECT club_name, COALESCE(club_winner,0) AS 'check', COUNT(*) AS points,
CASE
WHEN check = '0'
THEN points = '0'
ELSE check
END as Saleable
FROM clubs c
LEFT JOIN club_results cr ON c.club_id = cr.club_winner
GROUP BY club_name ORDER BY points DESC
你的意思是「當檢查=‘0’,則‘0’ELSE END點爲點」? –
是否要在表格中更新它,或者直接顯示它? –
這是MySQL還是Transact-SQL? – Black