Reputation: 737
Situation. CS-Cart has the following structure for options/variations tables.
[variant_options] table has a [combination] column.
[combination] stores the [option_id] and [variant_id] as
[option_id] underscore [variant_id] i.e. 1_2, 1_3...
To match the correct option and it's variant to each product i need to be able to reference those values. i.e. LEFT JOIN variant_name ON variant_name.variantid = (the value after the underscore in the combination column.)
How would i do this? Thanks
Upvotes: 1
Views: 71
Reputation: 425251
SELECT *
FROM combination c
LEFT JOIN
option o
ON o.id = SUBSTRING_INDEX(c.combination, '_', 1)
LEFT JOIN
variant v
ON v.id = SUBSTRING_INDEX(c.combination, '_', -1)
Upvotes: 1