MS Access Contains query
Asked Answered
P

2

5

How to write contain query for msaccess database

My table have column value ' CHOPE PARMA TERA 101'

my search keyword in PARMA.

How can I write contain query to retrieve the record ?

Pistareen answered 21/5, 2013 at 15:40 Comment(0)
F
15

Query in MS Access:

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

For standard SQL, it would be like '% PARMA %'

Note that the above statement would not find 'PARMA', 'CHOPE PARMA', or CHOPE PARMAHAM 101', or any value with that contains PARMA; to do so just remove the spaces in the search string, e.g. '*PARMA*'

select * from SomeTable Where SomeColumn Like '*PARMA*'
Front answered 21/5, 2013 at 15:49 Comment(4)
I tried but it doesn't work SELECT * FROM groups WHERE (Orgin LIKE '* PARMA *') only the below is working, SELECT * FROM groups WHERE (Orgin LIKE 'CHOPE PARMA TERA 101') is there way to look only for PARMAPistareen
Does it work with ALike instead of Like?: SELECT * FROM groups WHERE Orgin Alike '%PARMA%'Above
Had to look that up. Never heard of it. The answer appears to be maybe. #5167407Front
um just read your coment, try % instead of * with like first. According to the other link it depends on what mode you are in. I've no idea, haven't done access since about 93..Front
L
10

Are you asking about using the Like condition?
If so, there's more info here

MS Access: LIKE Condition (using wildcards) in Access 2003/XP/2000/97

The LIKE condition allows you to use wildcards in the where clause of an SQL statement in in Access 2003/XP/2000/97. This allows you to perform pattern matching. The LIKE condition can be used in any valid SQL statement - select, insert, update, or delete.

The patterns that you can choose from are:

* 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

For Example

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
Luna answered 21/5, 2013 at 15:48 Comment(1)
Is there any way to check a string starting with question mark (?) , FIELD Like '?' not workingBroadminded

© 2022 - 2024 — McMap. All rights reserved.