Code:
SELECT *
FROM jos_virtuemart_products INNER JOIN jos_virtuemart_product_categories
ON jos_virtuemart_products.virtuemart_product_id=jos_virtuemart_product_categories.virtuemart_product_id
INNER JOIN jos_virtuemart_product_customfields
ON jos_virtuemart_products.virtuemart_product_id=jos_virtuemart_product_customfields.virtuemart_product_id
WHERE virtuemart_category_id = '27'
AND custom_value BETWEEN '0' AND '.3'
OR custom_value BETWEEN '.3' AND '.6'
OR custom_value BETWEEN '.6' AND '.9'
Harken back to your 5th or 6th grade math class.
What is the value of
???
If you answered 35, go back to school.
Multiplication has higher priority than addition, so the correct answer is 23. You multiply first, then add.
If you wanted the 35 answers, you would have written
Same thing with AND and OR operators, in all computer languages.
AND has a higher precedence than OR.
So when you do
Code:
WHERE virtuemart_category_id = '27'
AND custom_value BETWEEN '0' AND '.3'
OR custom_value BETWEEN '.3' AND '.6'
OR custom_value BETWEEN '.6' AND '.9'
you are *REALLY* writing
Code:
WHERE ( virtuemart_category_id = '27' AND custom_value BETWEEN '0' AND '.3' )
OR custom_value BETWEEN '.3' AND '.6'
OR custom_value BETWEEN '.6' AND '.9'
so if custom_value matches either of those LAST TWO conditions, the first AND condition is ignored.
Now try
Code:
WHERE virtuemart_category_id = '27'
AND ( custom_value BETWEEN '0' AND '.3'
OR custom_value BETWEEN '.3' AND '.6'
OR custom_value BETWEEN '.6' AND '.9' )
Not to ask a dumb question, but what is the point of the three BETWEEN tests???
BETWEEN is *inclusive* so you could have accomplished the same thing with
Code:
WHERE virtuemart_category_id = '27'
AND custom_value BETWEEN '0' AND '.9'
and never had to worry about the OR conditions.