日期:2014-05-16  浏览次数:20709 次

求 where 问题
select *, IF(isnull(price1),price2, price1) as price
from goods
where price>100

会有一个问题Unknown column 'price' in 'where clause',这个price字段本身不存在,求实现语句。

------解决方案--------------------
select * from (
select *, IF(isnull(price1),price2, price1) as price
from goods) A
where price>100

OR

select *, IF(isnull(price1),price2, price1) as price
from goods
where IF(isnull(price1),price2, price1)>100