title: SPQuery : Joining lists and where in the foreign list
body: <p>Hello Sharepoint developers !</p>
  
  <p>Have you ever tried to do a join between lists and in both of those lists needed to place a where clause?
  I can do it in the first list, but can't find out how to place the where in the foreign list.</p>
  
  <p>I tried several solutions like this one :</p>
  
  <pre><code>using (SPWeb web = sps.OpenWeb())
              {
                  SPList spl = web.GetList(customers);
                  SPQuery query = new SPQuery();
                  query.Query = "&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Suspended'/&gt;&lt;Value Type='Boolean'&gt;0&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;";
                 query.Joins=@"&lt;Join Type='Inner' ListAlias='CountryList'&gt;&lt;And&gt;&lt;Eq&gt;&lt;FieldRef Name='Country' RefType='Id'/&gt;&lt;FieldRef List='CountryList' Name='ID'/&gt;&lt;/Eq&gt;&lt;Eq&gt;&lt;FieldRef List='CountryList' Name='Continent' /&gt;&lt;Value Type='Text'&gt;Europe&lt;/Value&gt;&lt;/Eq&gt;
                          &lt;/And&gt;&lt;/Join&gt;";
                  ....
  </code></pre>
  
  <p>But this is not working. I want to get all not suspended customers coming from all towns (another list) in Europe. So I need a where in the primary list (spl) to get not suspended customers and a where in the foreign list to get towns from europe only. I can't place my where in the Join element aparently. I tried to place it in the query, giving the list alias but it's not working either.</p>
  
  <p>would you have an idea ?
  thanks !</p>