group by:通过所查询的数据的某一字段或属性进行分组,最后显示组数,而不是具体数据。
例:
select id,userName from t_table group by id;
注意:
上述语句只能在mysql中跑通,在其他数据库例如SQL server或Oracle中都不能运行,因为在SQL server或Oracle中只能像如下写,group by以外的字段不能查询。
select id from t_table group by id;
group by:通过所查询的数据的某一字段或属性进行分组,最后显示组数,而不是具体数据。
例:
select id,userName from t_table group by id;
注意:
上述语句只能在mysql中跑通,在其他数据库例如SQL server或Oracle中都不能运行,因为在SQL server或Oracle中只能像如下写,group by以外的字段不能查询。
select id from t_table group by id;