为什么 Access 中的 LIKE 查询不返回任何记录? [英] Why does a LIKE query in Access not return any records?

查看:59
本文介绍了为什么 Access 中的 LIKE 查询不返回任何记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么原因吗

SELECT * FROM MyTable WHERE [_Items] LIKE '*SPI*'

不返回带有 OleDbAdapter.Fill(DataSet)OleDbCommand.ExecuteReader() 的任何记录?

does not return any records with OleDbAdapter.Fill(DataSet) or OleDbCommand.ExecuteReader()?

当我直接在 MS Access 中运行相同的 SQL 时,它返回预期的记录.另外,在相同的代码中,如果我将 SQL 更改为

When I run the same SQL in MS Access directly, it returns the expected records. Also, in the same code, if I change the SQL to

 SELECT * FROM MyTable 

返回所有记录.

推荐答案

Change your * to % as % is the wildcard search when使用 OLE DB.

Change your * to % as % is the wildcard search when using OLE DB.

SELECT * FROM MyTable WHERE [_Items] LIKE '%SPI%' 

这篇关于为什么 Access 中的 LIKE 查询不返回任何记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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