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

相關文章
相關標籤/搜索