Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference between [not (a like b)] and [a not like b]

Status
Not open for further replies.

muneco

Programmer
Nov 6, 2000
28
US
Attention Jet SQL experts,

I am looking for all rows in my_table where fld2 does not contain a comma. I have discovered that the following two SQL statements return a different set of rows using an Access 2000 query:

SELECT fld1 FROM my_table
WHERE not (((fld2) Like "*,*");

and

SELECT fld1 FROM my_table
WHERE (((fld2) not Like "*,*");

I would have expected them to be logically equivalent. Has anyone else experienced this, or can you please help me understand this? Thanks in advance for your help.
 
I would have used the INSTR function to return the position of a comma, and selected against that:

SELECT fld1 FROM my_table
WHERE Instr([fld2], ",") = 0)



Gets around having to figure out the different between NOT(In...) and NOT IN(...), which always gives me a headache.. :)



Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Can you give us a clue?

Is one result a subset of the other?

Are there rows that appear on one result and not the other and vice versa?

Can you provide specific examples of a "fld2" that is in one result and not the other?

Are the sql statements posted exactly the way they are run (since the parens are not balanced, I would guess that you have simplified the SQL that you are actually using -- what AND's and OR's do you have along with what you have shown?)

 
First of all, thank you kindly for both replies.

WildHare,
I was not aware of the "instr" function, thanks for educating me on that.

Zathras,
You are correct that I simplified the SQL. As it would happen, I am now having trouble duplicating the original pair of statements. But I now suspect that the source of my puzzlement was due to an additional condition (just as you inquired about!) that allowed two additional rows with null values through.

Thanks again to both of you gurus.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top