Original Post
Attributes_Stock Table
id | product_id | Attributes | Quantity
----------------------------------------------
1 | 44 | 46,41 | 9
2 | 44 | 46,42 | 5
3 | 44 | 43,49 | 3
4 | 44 | 44,42 | 5
5 | 45 | 52,41 | 1
6 | 45 | 38,41 | 5
7 | 45 | 52,52 | 6
8 | 45 | 35,41 | 5
9 | 46 | 55,43 | 0
Attributes Table
id | product_id | Option_id
------------------------------
41 | 44 | 12
42 | 44 | 32
43 | 44 | 54
44 | 44 | 23
45 | 44 | 21
46 | 44 | 13
Hi I am having a problem tying to solve a sql statement. Im not even sure can this be solved using SQL. Basically it is from a shopping cart. There are two tables containing information about the attributes (Colour and Size) of certain clothes products. The mixture of attributes is stored as a string in the Attributes column. You can see it as 46,41 etc . This is pointing to item 46 and item 41 in the Attributes table. I need to be able to get the corresponding Option_id for each of these two items. Is there an sql statement where I cound use the data found in one cell in the Attributes_Stock Table.Attributes column and retrieve the two corresponding Option_id's for instance if I look at the Attribute string 46, 42 I would like to be able to get the result as follows
Option_id_1 | Option_id_2
------------------------------
13 | 32
I hope I made myself clear as its pretty late. Thanks for any help. John.