语句是:
String sql="INSERT INTO note VALUES((select MAX(id) from note)+1,?,?,?)";
当没有插入数据时,select MAX(id) from note结果是null,所以,当note表里没有数据时,留言不到。
我想当note里没有数据时,id值默认值为0,怎么做?
...全文
1959打赏收藏
JSP 留言板,SQL server2008的设置初值的问题
语句是: String sql="INSERT INTO note VALUES((select MAX(id) from note)+1,?,?,?)"; 当没有插入数据时,select MAX(id) from note结果是null,所以,当note表里没有数据时,留言不到。 我想当note里没有数据时,id值默认值为0,怎么做?
isnull((select MAX(id) from note)+1,1)这句,
我还是需要分解听
isnull是来判断这个语句select MAX(id) from note是否为null?
((select MAX(id) from note)+1,1)后面的1是如果select MAX(id) from note是为null就赋值为1?