Answer the question
In order to leave comments, you need to log in
MySQL - how to make a selection from a many-to-many table?
Good afternoon, comrades!
Prompt please I study only MYSQL, but I can not make a composite query.
There are three tables: (games, genre and games-genre - games, genres, games-genres)
Games are stored by id - id_game
Genres by id_genre
And in the link table I did:
id_games and id_genres in order to create, for example, one game can be multiple genres.
Do I understand correctly that by creating several entries with the id of the game and the id of the genre, I will then receive all the genres for the game through a compound request? How is it implemented?
For example:
Game with id_game = 1
Two entries
id_games = 1 and id_genres = 1
id_games = 1 and id_genres = 2
Will the game with id=1 have two genres?
How to make a compound request? For example, display all genres for a game with id = 1?
Answer the question
In order to leave comments, you need to log in
SELECT g.* FROM genre g
LEFT JOIN games-genre gg ON g.id = gg.id_genres
WHERE gg.id_games = 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question