使用:
SELECt `id`, `hits` + `other_hits` AS `total_hits` FROM `something`HAVINg `total_hits` > 30
最早的MySQL允许引用列别名是
GROUP BY子句。后面的子句支持引用(
HAVINg,
ORDERBY)。大多数其他数据库不支持在之前引用表别名
ORDER BY,这通常需要使用派生表/内联视图:
SELECt t.id, t.total_hits FROM (SELECt `id`, `hits` + `other_hits` AS `total_hits` FROM `something`) t WHERe t.total_hits > 30
否则,您必须重用WHERe子句中的逻辑:
SELECt `id`, `hits` + `other_hits` AS `total_hits` FROM `something` WHERe `hits` + `other_hits` > 30



