IF条件不适用于条件

时间:2015-03-11 07:39:27

标签: mysql

我正在尝试下面查询条件是否正常

SELECT SUM(quantity) as qty 
FROM hud_allotment 
where IF (dvn_cd='$q') and IF(to_dvn='$q');  

请告诉我

1 个答案:

答案 0 :(得分:0)

如果可以使用where and

完成,则不需要
SELECT SUM(quantity) as qty 
FROM hud_allotment 
where dvn_cd='$q' and to_dvn='$q';