Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 张桌子:
products.product_attributes 包含与该产品相关的所有属性标识符的连续列表。但我的问题在于排序,concat 列表包含手动指定的顺序中的所有标识符,但这对结果的顺序没有影响。
如何使用 concat 列表来识别订单?
查询示例:
SELECT * FROM attributes WHERE attribute_id IN(products.product_attributes)
感谢@Raymond Nijland,不那么老套的解决方案:
SELECT DISTINCT attributes.* FROM attributes, products WHERE EXISTS(SELECT 1 FROM products WHERE FIND_IN_SET(attribute_id, product_attributes) IS NOT NULL);