SELECT user_id, group_id, COUNT(status) - SUM(status) AS contract FROM tp_contract GROUP BY user_id HAVING group_id = 18 AND COUNT(status) - SUM(status) > 0 LIMIT 0,10
select name as name1 from table1 where name1='aaa';
上面的运行有问题, 字段别名不能直接在谓词部分引用,表别名可以。
有人解释为MySql中列的别名本来是返回结果的时候才显示的,不在SQL解析时候使用
改成select name as name1 from table1 having (name1='aaa');即可
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。