title: Trouble with XQuery SQL statement to get correct parent/child value
body: <p>XML Schema: (Assumes that the XMLNAMESPACES are already set AS a and b)</p>
  
  <pre><code>&lt;Layer1 xmlns="a"&gt;
    &lt;Layer2 xmlns="b"&gt;
      &lt;Layer3&gt;
        &lt;id&gt;val1&lt;/id&gt;
        &lt;data&gt;False&lt;/data&gt;
      &lt;/Layer3&gt;
      &lt;Layer3&gt;
        &lt;id&gt;val2&lt;/id&gt;
        &lt;data&gt;True&lt;/data&gt;
      &lt;/Layer3&gt;
    &lt;/Layer2&gt;
  &lt;/Layer1&gt;
  </code></pre>
  
  <p>I am using this bit of sql to attempt to accomplinsh my task.</p>
  
  <pre><code>ITEM.value('(/a:Layer1/b:Layer2/b:Layer3)[1]', 'varchar(max)') AS ReturnValue
  </code></pre>
  
  <p>What I am trying to do is get only the true values where id='val2' AND data='True'. Something like this:</p>
  
  <pre><code>ITEM.value('(/a:Layer1/b:Layer2/b:Layer3[id="val2" and data="True"]/b:data)[0]', 'varchar(max)') AS ReturnValue
  </code></pre>
  
  <p>For some reason the above returns null. I'd assume it is a syntax error.</p>
  
  <p>In this query I would like the value to be returned as True from any Layer3 Parent where the id and data are following the conditions. I'd appreciate any help and thank you in advance.</p>