时间:2019-03-17 标签:c#Sqlstatement之间
我正在尝试对客户账单进行排序,并且需要按不同时间段对它们进行排序。
我一直在尝试的是:
(select billing_date from [transaktions]
between '" + start + "' and '" +stop+"' where konto_nr = @konto_nr")
also
(select billing_date from [transaktions] where konto_nr = @konto_nr" between '" + start + "' and '" +stop+"')
start = 日期的开始时间段 stop = 周期结束
我收到的错误消息是
关键字附近的语法不正确 “之间”。
I'm trying to sort customers billings and i need to sort them by different time periods.
What I've been trying is:
(select billing_date from [transaktions]
between '" + start + "' and '" +stop+"' where konto_nr = @konto_nr")
also
(select billing_date from [transaktions] where konto_nr = @konto_nr" between '" + start + "' and '" +stop+"')
start = the starting period of the date
stop = the ending of the period
The error message I'm getting is
Incorrect syntax near the keyword
'between'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先:您不应该永远将 SQL 语句连接在一起!这为 SQL 注入攻击敞开了大门……
其次:您需要将
BETWEEN
子句放入WHERE
子句中:First of all : you should never concatenate together your SQL statement! That's a big big open door for SQL injection attacks....
Second: you need to put your
BETWEEN
clause into aWHERE
clause:您的语法应该类似于
您正在使用的明显的相应列和变量名称。是的,您将“billing_date”引用为选定列,但 WHERE 可以测试条件的其他列,因此您也必须在那里明确标识它。
Your syntax should be something like
of the obvious respective columns and variable names you are working with. Yes, you referred to the "billing_date" as a selected column, but the WHERE can be testing OTHER columns of criteria so you have to explicitly identify it there too.