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.
我想使用这样的sql:
select * from product where productId IN (select RelatedProductIds FROM product where productID = 11)
RelatedProductIds包含'2286,11212,11031,11212,11212,4082,9339,9214'
RelatedProductIds
'2286,11212,11031,11212,11212,4082,9339,9214'
你有什么建议吗?
采用FIND_IN_SET()
FIND_IN_SET()
SELECT a.* FROM Product a INNER JOIN Product b ON FIND_IN_SET(a.productId, b.RelatedProductIds) > 0 WHERE b.productID = 11
作为建议,您应该正确规范化表格。在列中保存逗号分隔值是一个糟糕的设计。