我有一个 MySQL 语句,它执行内部SELECT
并将结果作为伪列返回。我想在我的WHERE
子句中使用这个伪列的结果。我当前的 SQL 语句如下所示:
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 子句'中的未知列 'price'
我怎样才能解决这个问题并实际使用price
我的WHERE
子句中的值?