如何在SQL语句中使用“Between”? [英] How to Use 'Between' in SQL Statement?

查看:98
本文介绍了如何在SQL语句中使用“Between”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SLQ语句,使用提示从用户获取两个代码的值。这应该是一件容易的事,但结果并不是我所期望的。谁能发现问题?当我输入8000作为起始ID而8999输入结束ID时,我只需要8000到8999之间的ActID,但我得到的代码介于8000和8999之间,代码介于80000和89999之间,代码介于800000和899999之间!很奇怪。 ActID字段是文本字段,并且所有ID都具有前导空格 8000"是8000的活动ID和 80000"是80000的ID。此查询应仅评估ActID的正确5个字符。


任何帮助将不胜感激!

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号

解决方案

试试这个:

展开 | 选择 | Wrap | 行号


雅 - 我应该在原帖中说这个。这给了我与''Between ...''语句相同的结果。

展开 | 选择 | Wrap | 行号


I对于最新情况没有一个很好的解释,但我可以建议尝试:

展开 | 选择 | Wrap | 行号

I have a SLQ Statement using a prompt to get the value of two codes from the user. This should be an easy thing but the result is not what I expect. Can anyone spot the problem? When I type in 8000 for the start ID and 8999 for the end ID, I want only ActID between 8000 and 8999 but I get codes between 8000 and 8999 as well as codes between 80000 and 89999, and codes between 800000 and 899999! Very odd. The ActID field is a text field and all ID''s have leading spaces " 8000" is the Activity ID for 8000 and " 80000" is the ID for 80000. This query should only evaluate the right 5 characters of the ActID.

Any help would be appreciated!

Expand|Select|Wrap|Line Numbers

解决方案

try this:

Expand|Select|Wrap|Line Numbers


Ya - I should have said this in my original post. This gives me the same results as the ''Between...'' statement.

Expand|Select|Wrap|Line Numbers


I dont have a good explanation of whats going on, but I can suggest to try:

Expand|Select|Wrap|Line Numbers


这篇关于如何在SQL语句中使用“Between”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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