常用的SQL语句

在做web开发时经常用到的一些SQL语句

 

1 统计记录总数

select  count(*)  from tablename;

 

2 数据库分页

select  *  from  tablename  order  by id  desc  limit "+((pageNo-1)*pageSize)+","+pageSize

 

pageNo 是从页面传进来的页码值, pageSize 是每一页要显示的记录数

 

3 获得最新插入的记录

select * from t_notice where id=(select max(id) from t_notice)

你可能感兴趣的:(sql,Web)