0

Error 1054: Unknown column 'status' in 'where clause'从 PHP 运行以下查询时出现错误。它可以从 phpMyAdmin、mysql 和 Toad for Mysql 运行,并且状态是表中的现有列product_to_supplier

( 
SELECT 
    pts.supplier_id AS supplier_id,
    CASE 
        WHEN IFNULL( ps.price, 0 ) > 1 AND IFNULL ( ps.price, 0 ) < pts.price THEN ps.price 
        ELSE pts.price 
    END AS price 
FROM egycart.`product_to_supplier` pts
         LEFT JOIN egycart.`product_special` ps ON pts.product_id = ps.product_id AND pts.supplier_id = ps.supplier_id 
WHERE pts.product_id = '887'
AND pts.status = '887' 
AND pts.quantity >0 
ORDER BY price 
) 
UNION DISTINCT 
( 
SELECT 
    pts.supplier_id AS supplier_id, 
    CASE 
        WHEN IFNULL( ps.price, 0 ) >1 AND IFNULL( ps.price, 0 ) < pts.price THEN ps.price 
    ELSE pts.price 
END AS price 
FROM product_to_supplier pts 
         LEFT JOIN product_special ps ON pts.product_id = ps.product_id AND pts.supplier_id = ps.supplier_id 
WHERE pts.product_id = '887' 
AND pts.status = '887' 
ORDER BY price 
) 
LIMIT 0 , 1

我环顾四周,但找不到一个好的答案。

谢谢

4

1 回答 1

0

@rsanchez:非常感谢您的注意,我添加了数据库名称并且查询工作正常。

于 2013-11-10T13:08:34.700 回答