title: SQL query not returning the criteria set
body: <p>I am developing a flowerbed planting system, and have written an SQL statement which queries 8 tables in order to return a list of suitable plants. </p>
  
  <p><strong>Table structure:</strong> <a href="http://pastebin.com/0DUYQis1" rel="nofollow">http://pastebin.com/0DUYQis1</a> [outputted from phpmyadmin]</p>
  
  <p><strong>Example Data:</strong> <a href="http://gyazo.com/13dad0b3370b5053dbcad2a32013a54a" rel="nofollow">http://gyazo.com/13dad0b3370b5053dbcad2a32013a54a</a> / <a href="http://gyazo.com/1bd313adb3e8ccd01354c979e69fd059" rel="nofollow">http://gyazo.com/1bd313adb3e8ccd01354c979e69fd059</a></p>
  
  <p><strong>SQL Statement:</strong></p>
  
  <pre><code>SELECT Plant.Plant_ID, Plant.Plant_Quantity, Plant.Plant_Price, Plant.Plant_Description, Plant.Plant_Latin_Name, Plant.Plant_Common_Name, Plant.Plant_Height, Plant.Plant_Spread, Plant.Plant_Type, Plant.Plant_Family, Plant.Plant_Picture, Plant_Aspect.Plant_Aspect, Plant_Flower_Colour.Plant_Flower_Colour, Plant_Flower_Colour.Plant_Season, Plant_Foliage_Colour.Plant_Foliage_Colour, Plant_Foliage_Colour.Plant_Season, Plant_Moisture.Plant_Moisture, Plant_Soil_PH.Plant_Soil_PH, Plant_Soil_Type.Plant_Soil_Type, Plant_Sun_Type.Plant_Sun_Type 
  
  FROM Plant 
  
  INNER JOIN Plant_Aspect ON Plant.Plant_ID = Plant_Aspect.Plant_ID 
  INNER JOIN Plant_Flower_Colour ON Plant.Plant_ID = Plant_Flower_Colour.Plant_ID 
  INNER JOIN Plant_Foliage_Colour ON Plant.Plant_ID = Plant_Foliage_Colour.Plant_ID 
  INNER JOIN Plant_Moisture ON Plant.Plant_ID = Plant_Moisture.Plant_ID
  INNER JOIN Plant_Soil_PH ON Plant.Plant_ID = Plant_Soil_PH.Plant_ID 
  INNER JOIN Plant_Soil_Type ON Plant.Plant_ID = Plant_Soil_Type.Plant_ID 
  INNER JOIN Plant_Sun_Type ON Plant.Plant_ID = Plant_Sun_Type.Plant_ID 
  
  WHERE Plant_Aspect.Plant_Aspect = 'East-facing'
  OR Plant_Aspect.Plant_Aspect = 'Any'
  AND Plant_Soil_Type.Plant_Soil_Type = 'Sand' 
  OR Plant_Soil_Type.Plant_Soil_Type = 'Any'
  AND Plant_Moisture.Plant_Moisture = 'Well-drained' 
  OR Plant_Moisture.Plant_Moisture = 'Any'
  AND Plant_Soil_PH.Plant_Soil_PH = 'Acid'
  OR Plant_Soil_PH.Plant_Soil_PH = 'Any'
  AND Plant_Foliage_Colour.Plant_Foliage_Colour = 'Green'
  AND Plant_Foliage_Colour.Plant_Season = 'Winter'
  OR Plant_Foliage_Colour.Plant_Season = 'Any'
  AND Plant_Flower_Colour.Plant_Flower_Colour = 'Orange'
  AND Plant_Flower_Colour.Plant_Season = 'Winter'
  OR Plant_Flower_Colour.Plant_Season = 'Any'
  
  GROUP BY Plant_ID;
  </code></pre>
  
  <p>I was expecting the query to return only those plants that have a record matching the search criteria, ie. only those plants that can be planted in the season 'Winter' or 'Any', but instead it is returning plants it shouldn't be.</p>
  
  <p>For example: <a href="http://gyazo.com/d2ca989fc6def79854a1d9b11e4bc310" rel="nofollow">http://gyazo.com/d2ca989fc6def79854a1d9b11e4bc310</a> - <code>Plant_ID: 1</code> contains only one record in the <code>Plant_Flower_Colour</code> table - Dark Blue during Spring. Why is it this record has been returned? It's as if the trailing <code>AND</code>s and <code>OR</code>s are being ignored.</p>
  
  <p>Any help would be much appreciated!</p>