具有参数和通配符的SQL LIKE运算符 [英] SQL LIKE operator with parameters and wildcards

查看:81
本文介绍了具有参数和通配符的SQL LIKE运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询,我想返回名称中具有特定字符串且两侧带有通配符的所有客户端.因此,输入的内容可能是史密斯",我想返回约翰·史密斯公司"或史密斯与兄弟"之类的所有内容.我希望得到[Client]的提示,所以我这样设置SQL:

I have a query where I want to return all Clients that have a certain string in the name with wildcards on either side. So the input could be "Smith" and i want to return all things like "The John Smith Company" or "Smith and Bros". I want [Client] to be prompted so I set up the SQL like this:

PARAMETERS Client Text ( 255 );
SELECT *
WHERE (((tbl_IncomingChecks.Client) Like'%' + [Client] + '%') 
ORDER BY tbl_IncomingChecks.Client;

查询未返回任何结果.请帮助

The query is not returning any results. Please help

推荐答案

MS Access使用*作为通配符,而不是%,因此您的查询将尝试匹配文字'%'字符.除非您使用的是ADO,否则请使用*.

MS Access uses * as a wildcard not %, so your query will be trying to match literal '%' characters. Use * instead unless you are using ADO.

http://office.microsoft.com/zh-CN/access-help/like-operator-HP001032253.aspx

这篇关于具有参数和通配符的SQL LIKE运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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