SELECT(IF(IN query.
- by Harold
There are 3 tables. Products, Options and Prod_Opts_relations. The latter holds product_id and option_id so i should be able to figure out which options are selected for any given product.
Now i want to retrieve all options from the options table where the value of an extra alias field should hold checked or unchecked depending on the existance of a mathing record in the relations table for a give product id.
Thus far i came up with this:
SELECT
IF(IN(SELECT id_option FROM prod_opt_relations WHERE id_product='18'),'y','n') AS booh
,optionstable.id AS parent_id
,optionstable.name_en AS parent_english
,optionstable.name_es AS parent_spanish
FROM product_options AS optionstable
WHERE 1
resulting in syntax errors.
Alas i just cannot figure out where things go wrong here