You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and attribute_quantity < 2 and attribute_quantity > 0' at line 5 select option_name, attribute_name, attribute_quantity
from tbl_option, tbl_option_attribute
where tbl_option.option_id = tbl_option_attribute.option_id
and tbl_option.item_id =
and attribute_quantity < 2 and attribute_quantity > 0