0

我在 MS Access 中有一个文本字段,它的文本如下:

bla bla bla [hhh] bla bla bla [kkkd]
blo blo blo blo [ttt] blo blo blo [ppp]
jh asdjahsuz uizasdui  asudz j jksdf 

我正在尝试搜索该字段中包含“[somthing]”的所有记录。

SELECT pruefhinweis
FROM tb_bauteile
WHERE pruefhinweis  LIKE '%[%]%'

但是这个 SQL 不起作用,你能告诉我我该怎么做这个工作吗?

4

3 回答 3

1

匹配模式中的方括号并不直观。请参阅帮助主题“在字符串比较中使用通配符”

您可以使用开括号 ([ )、问号 (?)、数字符号 (#) 和星号 (*) 的特殊字符直接匹配自己,前提是它们被括在括号中。您不能在组内使用右括号 ( ]) 来匹配自身,但可以在组外将其用作单个字符。

这些中的任何一个都将通过从 DAO 运行的查询返回您想要的内容(例如,在使用查询设计器的 Access 会话中)。

SELECT b.pruefhinweis
FROM tb_bauteile AS b
WHERE b.pruefhinweis Like '*[[]*]*';

SELECT b.pruefhinweis
FROM tb_bauteile AS b
WHERE b.pruefhinweis ALike '%[[]%]%';

在 ADO 中,您可以使用第二个查询或这个...

SELECT b.pruefhinweis
FROM tb_bauteile AS b
WHERE b.pruefhinweis Like '%[[]%]%';
于 2013-09-17T07:35:41.200 回答
1

尝试这个:

SELECT pruefhinweis
FROM tb_bauteile
WHERE pruefhinweis LIKE '*[[a-z]]*';

或者

SELECT b.pruefhinweis
FROM tb_bauteile AS b
WHERE b.pruefhinweis Like '*[[]*]*';
于 2013-09-17T07:08:24.933 回答
0
SELECT pruefhinweis
FROM tb_bauteile
WHERE pruefhinweis  LIKE '*[*]*'
于 2013-09-17T06:54:39.717 回答