I have a many to many relationship, and need to decide whether to create another table for it - or to store the relationship in a table with a string (CSV)... in other words:
EXAMPLE: tbl_Team tbl_Fan
(optional): tbl_fanTeam I want to be able to pick all fans of a team, or pick an individual fan and see all teams that they are a fan of.
What is the best m开发者_Go百科ethod in my SQL call, is it with using JOIN with a 3rd relational table (tbl_fanteam) or to place all the values in one of the existing two tables? Hope this makes sense...
When you use JOIN ... ON a.x = b.y
the database can take advantage of indexes to speed up the query.
When you use FIND_IN_SET
the indexes cannot be used so it will require a full scan. This will be slow if your tables have many rows.
精彩评论