Page 1 of 1

BETWEEN query not working

Posted: Wed Aug 08, 2007 5:03 am
by Wardy7
Having problems getting one part of a query working on a site. It's just the last part of the query where I am searching for records that are set between a certain year.

Code: Select all

$query  = "SELECT * FROM *MYTABLE* WHERE make='$make' AND model LIKE '%$model%' AND WHERE $year between madefrom AND madeto LIMIT $limitvalue, $limit";
So the above searches that the year that was selected is between the "madefrom" year and the "madeto" year (well it should but it isn't working, can anyone help please?! :)

I have also tried changing the last bit to this but still had no luck gettign it to work

Code: Select all

WHERE $year between datepart(yy,madefrom) AND datepart(yy,madeto)
Cheers
Wardy

Posted: Wed Aug 08, 2007 6:10 am
by VladSun
You have double "WHERE" in you query - remove the second one.

Posted: Wed Aug 08, 2007 6:42 am
by Wardy7
Soooo simple. Nice one mate :)

Cheers
Wardy