简体   繁体   English

在Access 2010中执行SQL子查询时,“条件表达式中的数据类型不匹配”

[英]“Data type mismatch in criteria expression” when doing SQL subquery in Access 2010

Here is my simplified code (little more than some basic elements to cause the SQL not to execute): 这是我的简化代码(除了使SQL无法执行的一些基本元素之外):

select *
from (
    select replace(mytxtfield, "llama", "") as badones 
    from XYZ
)
where badones is not null;

The outer query runs fine when the WHERE cause is: 当WHERE原因是时,外部查询运行良好:

 badones like "ZZZ-[0-9][0-9][0-9]"

but it breaks when the WHERE cause includes more than one LIKE (of any digit matching pattern) such as: 但是当WHERE原因包含多个(任何数字匹配模式的)LIKE时,它将中断,例如:

badones like "ZZZ-[0-9][0-9]" OR 
badones like "ZZZ-[0-9][0-9][0-9]"

More info: 更多信息:

  • mytxtfield is of type Text mytxtfield的类型为Text
  • It doesn't matter if there is a WHERE cause in the inner query to check eliminate null / empty strings. 内部查询中是否存在WHERE原因无关紧要,以检查消除空/空字符串。
  • 64-bit office 64位办公室

Since your sub-query returns the alias "badnews", you must use it in place of "badones" in your outer query. 由于子查询返回别名“ badnews”,因此您必须在外部查询中使用它代替“ badones”。 The following produces no errors: 以下不会产生任何错误:

SELECT *
FROM (select replace(mytxtfield, "llama", "") as badnews 
    from XYZ
)  
WHERE (((badnews) Like "ZZZ-[0-9][0-9]" Or (badnews) Like "ZZZ-[0-9][0-9][0-9]"));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 数据类型不匹配条件表达式中访问2010 SQL INSERT语句 - Data Type Mismatch in criteria expression Access 2010 with SQL Insert Statement MS Access SQL'条件表达式中的数据类型不匹配',因为在子查询中滤除了空值 - MS Access SQL 'Data type mismatch in criteria expression' due to null value filtered out in subquery “条件表达式中的数据类型不匹配。” ACCESS 2010和C# - “Data type mismatch in criteria expression.” ACCESS 2010 and C# SQL Access 2010按日期查询“条件表达式中的数据类型不匹配”。 - SQL Access 2010 querying by date “Data type mismatch in criteria expression.” SQL 条件表达式 MS Access 中的数据类型不匹配 - SQL Data type mismatch in criteria expression MS Access 条件表达式MS Access SQL查询中的数据类型不匹配 - Data type mismatch in criteria expression MS Access SQL query 条件表达式中的数据类型不匹配 SQL Select In Access - Data type mismatch in criteria expression SQL Select In Access 查询访问数据库时条件表达式中的数据类型不匹配 - Data type mismatch in criteria expression when Query Access DB 将变量传递到sql查询时,ms访问数据类型在条件表达式中不匹配 - ms access data type mismatch in criteria expression when passing a variable into a sql query 具有计算表达式的子查询的条件表达式中的数据类型不匹配 - Data type mismatch in criteria expression for the subquery with calculated expression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM