I want to select data from a table using those two columns. I'm i trying to do is select the table where month is between February and August and year between 2003 and 2005 including the month of january for 2004 and 2005. I have tried this: `
$number = range(3, 8);
foreach($number as $key=> $value):
$where .= " Month ='$value' AND Year BETWEEN '2003' AND '2005' or " ;
endforeach;
if(strlen(trim($where)) > 0)
$where = substr(trim($where), 0, -2);`
$query = "SELECT * FROM myTable $where";
which return the following query
SELECT * FROM myTable WHERE Month ='2' AND Year BETWEEN '2003' AND '2005' or Month ='3' AND Year BETWEEN '2003' AND '2005' or Month ='4' AND Year BETWEEN '2003' AND '2005' or Month ='5' AND Year BETWEEN '2003' AND '2005' or Month ='6' AND Year BETWEEN '2003' AND '2005' or Month ='7' AND Year BETWEEN '2003' AND '2005' or Month ='8' AND Year BETWEEN '2003' AND '2005'
But the problem with my query is it is not selecting january of 2004 and 2005. Any one with an idea of how to do this?