如何编写msaccess数据库的包含查询
我的表格列值' CHOPE PARMA TERA 101'
PARMA 中的搜索关键字。
如何编写包含查询以检索记录?
答案 0 :(得分:11)
在MS Access中查询:
select * from SomeTable Where SomeColumn Like '* PARMA *'
对于标准SQL,它就像'% PARMA %'
请注意,上述声明不会找到'PARMA','CHOPE PARMA'或CHOPE PARMAHAM 101',或者
包含PARMA的任何值;这样做只需删除搜索字符串中的空格,例如'*PARMA*'
select * from SomeTable Where SomeColumn Like '*PARMA*'
答案 1 :(得分:8)
您是否在询问使用Like条件?
如果有,则有更多信息here
MS Access:LIKE条件(使用通配符)在Access 2003 / XP / 2000/97
中LIKE条件允许您在Access 2003 / XP / 2000/97中的SQL语句的where子句中使用通配符。这允许您执行模式匹配。 LIKE条件可用于任何有效的SQL语句 - 选择,插入,更新或删除。
您可以选择的模式是:
* allows you to match any string of any length (including zero length)
? allows you to match on a single character
# allows you to match on a single numeric digit
例如
Like 'b*' would return all values that start with b
Like '*b*' would return all values that contain b
Like '*b' would return all values that end with b
Like 'b?' would return all values that start with b and are 2 characters in length
Like 'b#' would return all values that start with b and are 2 characters in length
where the second character is a number