MySQL dynamic JOIN
问题 Let's say that I have these tables on my db: items categories weapons shields swords And I need to create a join like this: SELECT items.*, {swords}.* FROM items INNER JOIN categories ON categories.id = items.category_id # <-- here I know that the item is a sword INNER JOIN {swords} ON {swords}.item_id = item.id WHERE items.id = 12 But the {swords} part is dynamic since I found that an item is a sword checkgin the categories.name field. The query will change if the categories.name is " shield