Note that there are some explanatory texts on larger screens.

plurals
  1. POLogical operator AND having higher order of precedence than IN
    text
    copied!<p>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 ?</p> <pre><code>SELECT Song, Released, Rating FROM Songs WHERE Released IN (1967, 1977, 1987) AND SongName = ’WTTJ’ </code></pre> <p>thanx</p> <p><strong>EDIT:</strong></p> <p><strong>Egrunin</strong> and <strong>ig0774</strong>, I’ve checked it and unless I totally misunderstood your posts, it seems that </p> <p><code>WHERE x &gt; 0 AND x &lt; 10 OR special_case = 1</code> </p> <p>is indeed the the same as </p> <p><code>WHERE (x &gt; 0 AND x &lt; 10) OR special_case = 1</code></p> <p>Namely, I did the the following three queries </p> <pre><code>SELECT * FROM Songs WHERE AvailableOnCD='N' AND Released &gt; 2000 OR Released = 1989 SELECT * FROM Songs WHERE (AvailableOnCD='N' AND Released &gt; 2000) OR Released = 1989 SELECT * FROM Songs WHERE AvailableOnCD='N' AND (Released &gt; 2000 OR Released = 1989) </code></pre> <p>and as it turns out the following two queries produce the same result:</p> <pre><code>SELECT * FROM Songs WHERE AvailableOnCD='N' AND Released &gt; 2000 OR Released = 1989 SELECT * FROM Songs WHERE (AvailableOnCD='N' AND Released &gt; 2000) OR Released = 1989 </code></pre> <p>while </p> <pre><code>SELECT * FROM Songs WHERE AvailableOnCD='N' AND (Released &gt; 2000 OR Released = 1989) </code></pre> <p>gives a different result</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload