How to use "how" and "dislike" in MSAccess SQL for the same field?

I would like to filter out all lines:

field like "*AA*" and field not like "*BB*"

But this returns everything, and does not show all rows containing AA, and does not contain BB.

Now it works, as expected, just restarted ms access ...

Sorry for my typo ...: updated

+3
source share
6 answers

Try the following:

filed like "*AA*" and filed not like "*BB*"
+8
source

What I found out is that MS Access will reject - don't like "BB *" - if it is not enclosed in PARENTHESES, unlike "BB *" - this is normal without parentheses.

I tested them in MS Access 2010 and they are all valid:

  • Like "BB"

  • (Like "BB")

  • ( "BB" )

+1

;

where (field like "*AA*" and field not like "*BB*")
0

:

field like "*AA*" and field not like "*BB*"

.

Could you post some examples of your data?

0
source

Not sure if this is still preserved, but I assume you need something like

((field Like "AA*") AND (field Not Like "BB*"))
0
source

If you do this in VBA (and not in the request), then: where the field is of type “AA” and the field is not like “BB”, then it will not work.

You will need to use: where is the field of type "AA" and the field of type "BB" = false, then

0
source

All Articles