【问题标题】:How do I query "where isNumeric(col), and col > 0" in access如何在访问中查询“where isNumeric(col), and col > 0”
【发布时间】:2016-07-09 07:10:47
【问题描述】:

我正在清理 access 数据库中的一些数据,其中应该是数字且 >0 的文本属性包含非数字数据或

因为Access没有短路,所以不能做a

create table cleaned_up as
select * from a_mess
where isNumeric(col) and col >0

有没有办法解决

create table cleaned_up as
select * from (
  select * from a_mess
  where isNumeric(col)
)
where col > 0

【问题讨论】:

  • Access 不是在处理0=FALSE-1=TRUE(或者换句话说:0=FALSEanyValueNotEqualToZero=TRUE 吗?
  • col 中有哪些值?如果你写where IsNumeric(col) and CDbl(col)>0会发生什么?我不知道如果第一个条件为假,Access是否会停止......
  • @GordonLinoff col 甚至包含204 WK 等垃圾。
  • col like "[1-9]*" and col not like '*[^0-9]*'

标签: sql ms-access short-circuiting


【解决方案1】:

只关注SELECT 开始...

SELECT *
FROM a_mess
WHERE
        IsNumeric(col)
    AND Val(Nz(col, 0)) > 0;

然后您可以将该查询调整为 SELECT ... INTO 语句(Access UI 称之为“生成表”查询)以将结果集保存为表...

SELECT *
INTO cleaned_up
FROM a_mess
WHERE
        IsNumeric(col)
    AND Val(Nz(col, 0)) > 0;

【讨论】:

    【解决方案2】:

    您可以使用 Val,因为它为以非数字字符开头的字符串返回 0:

    create table cleaned_up as
    select * from a_mess
    where Val(col) > 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 2018-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多