Using column alias in WHERE clause of MySQL query produces an error

后端 未结 8 1266
北荒
北荒 2020-11-22 03:40

The query I\'m running is as follows, however I\'m getting this error:

#1054 - Unknown column \'guaranteed_postcode\' in \'IN/ALL/ANY subquery\'

<
8条回答
  •  無奈伤痛
    2020-11-22 04:13

    Maybe my answer is too late but this can help others.

    You can enclose it with another select statement and use where clause to it.

    SELECT * FROM (Select col1, col2,...) as t WHERE t.calcAlias > 0
    

    calcAlias is the alias column that was calculated.

提交回复
热议问题