结果集我有进行内SELECT
并返回结果作为伪列的MySQL的语句。我想在我的WHERE
子句中使用这个伪列的结果。我现在的SQL语句如下所示:过滤器的MySQL结果通过的内选择
SELECT
product.product_id,
product.range_id,
product.title,
product.image,
product.image_text,
product.friendly_url,
attribute.comfort_grade_id,
category.category_id,
category.category AS category_name,
category.friendly_url AS category_friendly_url,
(SELECT price_now FROM product_bedding_sizes AS size WHERE size.product_id = product.product_id ORDER BY size.price_now ASC LIMIT 1) AS price
FROM
products AS product
LEFT JOIN
categories AS category ON product.category_id = category.category_id
LEFT JOIN
product_bedding_attributes AS attribute ON product.product_id = attribute.product_id
$where
$order
LIMIT
?,?
不过,我得到运行查询时出现以下错误信息:
#1054 - 未知列 '价格' 在 'where子句'
我怎样才能解决这个问题,在我的WHERE
条款实际使用的price
价值?
做到这一点哪里和你没有共享这个变量。 – 2013-02-15 16:37:53
是的。无论是'$ where'和'$ order'变量构建的查询之外,但'$ where'将包含类似'WHERE价格> 0 AND'price' <= 199'。 – 2013-02-16 11:12:34
你确定它的'price'列,而不是'price_now'因为它甾体抗炎药售价未知列 – 2013-02-16 11:15:08