mysql 高級sql

插入新的列sql

alter table  tablename add colmun name typeit

求個數table

select count(columnname) from tablenameast

求均值select

select avg(columnname)  from tablenameim

求最小值tab

select min(columnname)  from tablenameco

查前n個字段ab

select * from tablename limit N

sql裏面selct  last 能夠返回最後一個,可是我沒找到,因此查到能夠這麼實現

select columnname1 from tablename order by columnname2 limit 1

求最大、最小、總值

select max(columnname)/min(columnname)/sum(columnname) from tablename

sql group by 進行分組

select * from userinfo group by username order by id

相關文章
相關標籤/搜索