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.
我有以下两张表。如何查询表 B variant_id 在表 A 组合中匹配的位置?
TableA product_id combination ean 1 952_4038 123456789 2 946_3989 101010101 TableB variant_id desc 4038 text1 3989 text2
谢谢!
SELECT a.*, b.* FROM TableA a INNER JOIN TableB b ON a.combination LIKE CONCAT('%', b.variant_ID)
这个查询在大型数据库上非常慢。考虑正确规范您的表格。
我建议的表架构:
表A
表B
确保在链接字段上有索引。
后续问题:哪个表是主表和从属表?