Query Not Working - Why?

Hi Guys,

I have this query i need to do:

SELECT ClickID, AffID, Date, Time, IP, Referrer FROM `clicks`  WHERE (`Date` >= {$MONTHLY} AND `Date` <= {$MONTHLYTO} AND `ProID` =  '3' AND `ProID` =  '6')

But it keeps giving me errors, but if i remove the

 AND `ProID` =  '3' AND `ProID` =  '6'

part then it works fine but i only want it to select everything where the ProID values matches those 2 values.

Can anyone help me here please?

Thank you!

If it gives you errors, then please post the errors it gives you.

But I guess it just doesn’t return any results, because proID can’t be ‘3’ AND ‘6’ at the same time.
Use this instead:

AND `ProID` IN ('3', '6')

I think you are developing in PHP and the SELECT statement is including PHP variables ({$MONTHLY}). Sometimes these are not getting assigned a value and this can result in an incomplete SQL SELECT statement:


WHERE (`Date` >= {$MONTHLY} AND `Date` <= {$MONTHLYTO} ...

could generate

WHERE (`Date` >=  AND `Date` <= 10 ...

My suggestion is print off the SQL to see what is being sent to the database.