1、数据库表id为主键自增不为null,获取数据库表最新一条数据id,若数据库表为空,设置id值默认为0 select ifnull((select id from 表名 ORDER BY id DESC LIMIT 0,1),0) as id