mysql 插入须要用到当前表最大值的时候的语句

使用 insert into +select 的模式url

insert into sys_menu (menu_name,menu_url,parent_id,menu_order)
		select 'ccc','',0,
		(select IFNULL((select max(menu_order)from sys_menu),0))+1

核心在 IFNULL里面的select max也须要加上括号,防止,空表插入的时候报错问题code

相关文章
相关标签/搜索