我有以下查詢:mysql命令的結果通過總的權重
SELECT
p.`ID`,
(SELECT COUNT(`ID`) FROM `comments` c WHERE c.`post_id` = p.`ID`) AS `comments`,
(SELECT COUNT(`ID`) FROM `likes` l WHERE l.`post_id` = p.`ID`) AS `likes`
FROM `posts` p
我想根據第三列,這將是計算方式如下命令的結果:
order = comments * 6 + likes * 4
我如何創建這個「虛擬」列並在計算中使用另外兩個的結果?
謝謝!
謝謝!這工作完美:) – 2013-04-05 17:40:59