2013-05-21 141 views
2

如何編寫包含查詢MSACCESS數據庫的MS Access包含查詢

我的表有列值'CHOPE PARMA TERA 101' 在PARMA

我的搜索關鍵字。

如何編寫包含查詢來檢索記錄?

回答

6

查詢在MS Access:

select * from SomeTable Where SomeColumn Like '* PARMA *' 

對於標準SQL,它會像'% PARMA %'

請注意,上述聲明不會找到包含PARMA的任何值,包括PARMA,「PARMA」,「CHOPE PARMA」或CHOPE PARMAHAM 101'或 。這樣做只需刪除搜索字符串中的空格,例如'*PARMA*'

select * from SomeTable Where SomeColumn Like '*PARMA*' 
+0

我試過,但它不工作 SELECT * FROM 組 WHERE(淵源考LIKE '* PARMA *') 只有下面的工作,SELECT * FROM 組 WHERE(LIKE淵源考'CHOPE PARMA TERA 101')有沒有辦法只看PARMA –

+1

它是否與'ALike'一起使用而不是'Like'?':SELECT * FROM組別'Orgin''%PARMA%'' – HansUp

+1

不得不看一下。從來沒有聽說過。答案似乎是可能的。 http://stackoverflow.com/questions/5166907/ms-access-sql-any-reason-why-like-does-not-work –

7

您是否在問使用Like條件?
如果是的話,還有更多的信息here

MS訪問(使用通配符)LIKE條件在Access 2003/XP /97分之2000

LIKE條件允許您將SQL語句的where子句中使用通配符聲明在Access 2003/XP/2000/97中。這允許您執行模式匹配。 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