关于Sql查询 [英] Regarding Sql Query

查看:74
本文介绍了关于Sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何生成自动序列号?我使用了以下查询:

How to generate automatic serial number? I''ve used this query:

select isnull(max(BL_DueNo)+1,1) from BillForm where BL_Lno='" + BL_LnoCombo.Text + "'


但是它不会在10点之后生成.请告诉我正确的sql查询.


But it doesn''t generate after 10. Please tell me the correct sql query.

推荐答案

因为您正在从提供的值中获取BL_Lno的最大值.
在您的情况下,您需要从所有记录中找到MAX.

看看BL_Lno的值是否为 9 ,并且您将其递增为 10 ,但是您知道是否存在ID为 9 代表其他BL_LnoCombo吗?

如果要生成增量no,则不要使用自定义生成,请使用自动增量"列 [<会自行照顾的href ="http://www.w3schools.com/sql/sql_autoincrement.asp" target ="_ blank" title ="New Window"> ^ ].
Because you''re fetching maximum among where BL_Lno is from provided value.
and in the your scenario you need to find MAX from all record.

See if BL_Lno having a value of 9 and you''re incrementing it with 10, But do you know that there''s alerady a record for ID 9 for other BL_LnoCombo?

If you want to generate the incremental no then don''t go with custom generation, USE Auto Increment column[^] that will take care itself.


这篇关于关于Sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆