选择表< 400给出了不稳定的价值观

时间:2012-05-09 05:25:36

标签: php mysql select

$sql = "(SELECT * FROM   table1 WHERE col1 LIKE  '%Computers%'
AND PRICE <= 400
AND  BUYURL IS NOT NULL
AND  IMAGEURL IS NOT NULL )
UNION
(SELECT DISTINCT * FROM  table2 WHERE col2 LIKE  '%desktop computer%' 
AND PRICE <= 400
AND  BUYURL IS NOT NULL
AND  IMAGEURL IS NOT NULL )
ORDER BY  PRICE ASC";

上面的查询返回值,“Price”有时超过400。 有人可以帮忙吗? 感谢。

1 个答案:

答案 0 :(得分:4)

作为临时解决方案,您可以使用:

AND CONVERT(price, DECIMAL) <= 400

但是我强烈建议您更改它,例如DECIMAL(10,2)(其中2是您要存储的点之后的数字)