需求:取stock表中id最大值+1,作为下一个id值. 特殊情况:考虑到表中会没有值,max(id)会返回空,因此需要用case when进行判断. 实现一:select (case max(id) is null when true then 0 else max(id)+1 end) from stock 实现二:select (case (select count(*) from stock) when 0 then 0 else max(id)+1 end) from stock 效率
引用链接:http://cukes.info/step-definitions.html Data Tables Data Tables are handy for specifying a larger piece of data: Given the following users exist: | name | email | phone | | Aslak | aslak@email.com | 123 | | Matt | matt@email.com | 234 | | Joe |