在 MS Access 的 SQL 查询中将字符串数据类型转换为 Int

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3262217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:51:16  来源:igfitidea点击:

Cast string data type to Int in SQL QUery for MS Access

sqlms-accesscasting

提问by amol kadam

I am trying to write a query in access that will pull results that are in the database in a text Acually,I have RECEIPTNO Column whose datatype is TEXT in Table Membership, & I want to pull all the results from RECEIPTNO column where RECEIPTNO is BETWEEN 1 AND 10

我正在尝试在访问中编写一个查询,该查询将在文本中提取数据库中的结果 Acually,我有 RECEIPTNO 列,其数据类型为表成员中的 TEXT,并且我想从 RECEIPTNO 列中提取所有结果,其中 RECEIPTNO 是 BETWEEN 1 和 10

And I tried Below Code.

我试过下面的代码。

SELECT Cint(RECEIPTNO) FROM MEMBERSHIP where Cint(RECEIPTNO) BETWEEN 1 AND 10

Result is: Overflow ,Any Idea?

结果是:溢出,有什么想法吗?

回答by Fionnuala

Do you want:

你想要:

SELECT RECEIPTNO FROM MEMBERSHIP
WHERE Val(RECEIPTNO) BETWEEN 1 AND 10

回答by amol kadam

Ohhh I got the answer, & it's working

哦,我得到了答案,它正在起作用

& the Query Like

& 查询喜欢

SELECT Cint(RECEIPTNO) FROM MEMBERSHIP where RECEIPTNO BETWEEN 1 AND 10

回答by OpeBams

This gives you what you want. ss

这给了你你想要的。SS

SELECT RECEIPTNO FROM MEMBERSHIP
WHERE Val(RECEIPTNO & "") BETWEEN 1 AND 10

Others using Val(RECEIPTNO) will only TRY to work somehow half-heartedly where it does beacuse the system doesn not recognise the RECEIPTNO as text and so, it is funny to it to see you passing a number instead of a string. However, to convince the system that the format is actually a number, concatenate it with an empty string which I have done.

其他使用 Val(RECEIPTNO) 的人只会尝试以某种方式半心半意地工作,因为系统无法将 RECEIPTNO 识别为文本,因此,看到您传递的是数字而不是字符串,这很有趣。但是,为了让系统相信格式实际上是一个数字,请将它与我所做的空字符串连接起来。