Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql where子句中的未知列xxx使用联接、group by和全文_Mysql_Sql_Join_Group By_Mysql Error 1054 - Fatal编程技术网

Mysql where子句中的未知列xxx使用联接、group by和全文

Mysql where子句中的未知列xxx使用联接、group by和全文,mysql,sql,join,group-by,mysql-error-1054,Mysql,Sql,Join,Group By,Mysql Error 1054,我的问题出了什么问题 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 ...

我的问题出了什么问题

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子句,它将非常有效。。。那么我的别名有什么问题呢?

您需要使用
HAVING
(还有一些不太有用的:);
WHERE
子句在别名存在之前得到计算;)

您需要使用
HAVING
(并且有些没有帮助:);
WHERE
子句在别名存在之前得到计算;)