41

Sorry about the minimalistic title but I don't know how to describe it in short. I have three tables:

The table of groups

ID | Genre
-----------------
1  | Action
2  | Adventure
3  | Drama

Many to many table

GroupID | ElementID
-----------------
    3   |    1
    1   |    2
    2   |    2
    2   |    3
    3   |    3

And the table of elements

ID | Element
-----------------
1  | Pride and Prejudice
2  | Alice in Wonderland
3  | Curious Incident Of A Dog In The Night Time

All is fine and very simple. The SELECT I am trying to achieve is the following

ID | Element                                         |  Genre
-------------------------------------------------------------
1  | Pride and Prejudice                             | Drama
2  | Alice in Wonderland                             | NULL
3  | Curious Incident Of A Dog In The Night Time     | Drama

I want to select all the elements from the table Elements and set the genre field to Drama or null.

I'm trying to do this in MySQL.

Thank you in advance

4

1 に答える 1