I have this sql statement:
DECLARE @option_id INT;
SELECT DISTINCT product_options.option_id
INTO @option_id
FROM product_options,
product_options_descriptions
WHERE product_options.product_id = '31288'
AND product_options_descriptions.option_name = "Color";
SELECT @option_id;
Which works fine. What I would like to do is is use @option_id to select multiple ids into an array. However as far as I can tell DECLARE @var only works with single values and I can't find any information on array datatypes in sql.
In outline I want to do the following
declare @option_id;
SELECT @option_id;
DECLARE @id_array;
SELECT into @id_array WHERE id = @option_id;
DECLARE @return_array;
FOREACH @id IN @id_array {
@return_array[] = SELECT value FROM column where id = @id
}
SELECT @return_array
Does anyone know where I can find tutorials ect to achieve this?