Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 751463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:40:11+00:00 2026-05-14T14:40:11+00:00

I’ve read that logical operator AND has higher order of precedence than logical operator

  • 0

I’ve read that logical operator AND has higher order of precedence than logical operator IN, but that doesn’t make sense since if that was true, then wouldn’t in the following statement the AND condition got evaluated before the IN condition ( thus before IN operator would be able to check whether Released field equals to any of the values specified within parentheses ?

SELECT Song, Released, Rating
FROM Songs
WHERE
Released IN (1967, 1977, 1987)
AND
SongName = ’WTTJ’

thanx

EDIT:

Egrunin and ig0774, I’ve checked it and unless I totally misunderstood your posts, it seems that

WHERE x > 0 AND x < 10 OR special_case = 1

is indeed the the same as

WHERE (x > 0 AND x < 10) OR special_case = 1

Namely, I did the the following three queries

SELECT * 
FROM Songs 
WHERE AvailableOnCD='N' AND Released > 2000 OR Released = 1989

SELECT *
FROM Songs
WHERE (AvailableOnCD='N' AND Released > 2000) OR Released = 1989

SELECT *
FROM Songs
WHERE AvailableOnCD='N' AND (Released > 2000 OR Released = 1989)

and as it turns out the following two queries produce the same result:

SELECT * 
FROM Songs 
WHERE AvailableOnCD='N' AND Released > 2000 OR Released = 1989

SELECT *
FROM Songs
WHERE (AvailableOnCD='N' AND Released > 2000) OR Released = 1989

while

SELECT *
FROM Songs
WHERE AvailableOnCD='N' AND (Released > 2000 OR Released = 1989)

gives a different result

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:40:11+00:00Added an answer on May 14, 2026 at 2:40 pm

    Call me a n00b, but I always use parentheses in nontrivial compound conditions.

    SELECT Song, Released, Rating
    FROM Songs
    WHERE
        (Released IN (1967, 1977, 1987))
    AND
        SongName = ’WTTJ’
    

    Edited (Corrected, the point remains the same.)

    Just yesterday I got caught by this. Started with working code:

    WHERE x < 0 or x > 10
    

    Changed it in haste:

    WHERE x < 0 or x > 10 AND special_case = 1
    

    Broke, because this is what I wanted:

    WHERE (x < 0 or x > 10) AND special_case = 1
    

    But this is what I got:

    WHERE x < 0 or (x > 10 AND special_case = 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read that the ^ operator is the logical XOR operator in C#, but
I read that in shell, true command returns 0 => logical true. false command
I read that you should define your JavaScript functions in the <head> tag, but
In most of the book we read that cluster index is the physical order
I read this article: Logical Processing Order of the SELECT statement in end of
I read that you could call JavaScript code from a Java Applet by calling
I read that Domain Driven Design is about concentrating on the problem domain instead
I read that SQL exceptions are treated as normal exceptions in managed SPs; I
I read that defined styles are located at C:\Program Files\Microsoft Office\Office12\Bibliography\Style I use ISO
I read that some webmail services prefetch url links in emails. The GET request

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.