What are the operator precedences in this?

Post Reply
jkj2001
Posts: 142
Joined: Fri Mar 29, 2002 1:39 pm

What are the operator precedences in this?

Post by jkj2001 »

Someone ran a search like so, with no parentheses. I'm trying to understand just what was run:

select * from mytable where myfield like '"SC"' OR myfield like '"South Carolina"' AND myfield like 'newell' OR myfield like 'stanton' OR myfield like 'schiff'

I'm not 100% sure how the AND in the middle there is playing out. Thanks for helping clear my head on this.
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

What are the operator precedences in this?

Post by John »

The AND has a higher precedence, so it is like:

select * from mytable where
myfield like '"SC"' OR
(myfield like '"South Carolina"' AND myfield like 'newell') OR
myfield like 'stanton' OR
myfield like 'schiff'
John Turnbull
Thunderstone Software
jkj2001
Posts: 142
Joined: Fri Mar 29, 2002 1:39 pm

What are the operator precedences in this?

Post by jkj2001 »

Thanks, John.

Before I go, any chance I can slip one more question your way?

I've got this search:

select * from mytable where (myfield like 'binder "file folder" "fax cover" @0')

It returns appropriate hits mixed in with things like "Binder Tab File Folder", which I thought was a little strange, since I put "file folder" in quotes.

Does this happen because @0 doesn't run post-processing and therefore sort of ignores the quotes, at least in the prefix? Is it possible to run the @0 search with an exact match for "file folder"?
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

What are the operator precedences in this?

Post by John »

Maybe I'm missing something, but that looks like an appropriate hit, as both binder and "file folder" are in there, and only one would be required for a match.
John Turnbull
Thunderstone Software
Post Reply