Reputation: 16793
I have 2 tables:
products.product_attributes contains a concat list of all the attribute identifiers related to this product. But my problem is with the ordering, the concat list contains all of the identifers in a manually specified order, but this has no effect on the order of the results.
How can I use a concat list to identify the order?
Query example:
SELECT * FROM attributes WHERE attribute_id IN(products.product_attributes)
Upvotes: 0
Views: 60
Reputation: 12563
Thanks to @Raymond Nijland, less hacky solution:
SELECT DISTINCT attributes.* FROM attributes, products
WHERE EXISTS(SELECT 1 FROM products WHERE
FIND_IN_SET(attribute_id, product_attributes) IS NOT NULL);
Upvotes: 2