2

我的查询有什么问题?

SELECT ...
       MATCH(results.keywords) AGAINST('".DB::e($_POST['s'])."' IN BOOLEAN MODE) AS aaa,
       SUM( MATCH(tags.keywords) AGAINST('".DB::e($_POST['s'])."' IN BOOLEAN MODE) ) AS bbb
  FROM table1
  JOIN table2 ... JOIN table3 ...
 WHERE (aaa > 0   here the alias doesn't work!
        OR bbb > 0   here the alias doesn't work! )
GROUP BY table1.id
ORDER BY aaa DESC,  but here the alias works!
         bbb DESC  but here the alias works!

如果我删除 WHERE 子句效果很好......那么我的别名有什么问题?

4

1 回答 1

4

您需要使用HAVING此处此处,帮助较少:此处);该WHERE子句在别名甚至存在之前就被评估;)

于 2012-04-06T01:45:20.287 回答