title: SQL Difference Between Parameter and value
body: <p>Sorry if my heading was a bit misleading but not entirely sure how to phrase it.</p>
  
  <p>Why would there be a difference between the below two statements:</p>
  
  <pre><code>SELECT * 
  FROM tbl1 LEFT OUTER JOIN 
        tbl2 ON tbl1.num = tbl2.tbl1Num LEFT OUTER JOIN
        tbl3 ON tbl2.num = tbl3.tbl2Num
  WHERE tbl2.intNum = 123 OR 123 = -1
  </code></pre>
  
  <p>AND </p>
  
  <pre><code>DECLARE @intNum int = 123
  SELECT * 
  FROM tbl1 LEFT OUTER JOIN 
        tbl2 ON tbl1.num = tbl2.tbl1Num LEFT OUTER JOIN
        tbl3 ON tbl2.num = tbl3.tbl2Num
  WHERE tbl2.intNum = @intNum OR @intNum = -1
  </code></pre>
  
  <p>We ran the above two queries and it actually gave us different results? We ended up changing it to a Union to solve the problem but I would really like to understand why this happened.</p>
  
  <p>Thanks in advance!</p>