select * from (select count(id) idcount ,a1 a1 , a1_1 a1_1 ,a1_2 a1_2 , id id from table where a1='静安区' group by id ) area where area.idcount>1,大家帮我看看哪出问题了、谢谢!
select count(id) idcount ,a1 a1 , a1_1 a1_1 ,a1_2 a1_2 , id id from table where a1='静安区' group by id ?????? --你的字段名本来就是a1你干嘛还给它取个别名a1啊...... select 后面出现的列一定要出现在group by 后
select * from (select count(id) idcount ,a1 a1 , a1_1 a1_1 ,a1_2 a1_2 , id id from table where a1='静安区' group by id,a1,a1_1,a1_2 ) area where area.idcount>1
select count(id) idcount ,a1 a1 , a1_1 a1_1 ,a1_2 a1_2 , id id from table where a1='静安区' group by id 你这里用了集记函数count(),所以group by里面,应该把集记函数以外的列加进去。所以应该改成select * from (select count(id) idcount ,a1 a1 , a1_1 a1_1 ,a1_2 a1_2 , id id from table where a1='静安区' group by id,a1,a1_1,a1_2 ) area where area.idcount>1
select * from (select count(id) idcount ,a1 a1 , a1_1 a1_1 ,a1_2 a1_2 , id id from table where a1='静安区' group by id,a1,a1_1,a1_2 ) area where area.idcount>1
?????? --你的字段名本来就是a1你干嘛还给它取个别名a1啊......
select 后面出现的列一定要出现在group by 后
from table 把table 换成表名