mysql - Make subquery with like -
i have following 2 tables. how can make query table b variant_id matched in table combination?
tablea product_id combination ean 1 952_4038 123456789 2 946_3989 101010101 tableb variant_id desc 4038 text1 3989 text2
thanks!
select a.*, b.* tablea inner join tableb b on a.combination concat('%', b.variant_id)
this query terribly slow on large databases. consider normalizing table properly.
my proposed table schema:
tablea
- productid (1)
- intcolumn (952)
- combination (4038)
- ean (123456789)
tableb
- combination (4038)
- desccolumn (text) [don't use reserved keyword]
make sure have indexes on linking fields.
followup question: table main table , dependent table?