Hallo, ich habe folgende Tabelle:
BOOK
--------------------------------
name | seller_id | buyer_id
--------------------------------
buch1 | 1 | 1
buch2 | 2 | 2
buch3 | 3 | null
buch4 | 4 | 3
SELLER
---------------------
id | person_id
---------------------
1 | 1
2 | 2
3 | 3
4 | 4
BUYER
---------------------
id | person_id
---------------------
1 | 5
2 | 6
3 | 7
PERSON
---------------------
person_id | name
---------------------
1 | person1
2 | person2
3 | person3
4 | person4
5 | person5
6 | person6
7 | person7
Ich möchte folgende Ergebnis mit JOIN (LEFT, RIGHT, usw) bekommen :
Ergebnis
---------------------------------------------------
Bookname | Sellername | Buyername
---------------------------------------------------
buch1 | person1 | person5
buch2 | person2 | person6
buch3 | person3 | null
buch4 | person4 | person7
Kann jemand mir verraten, wie die SQL-Anfrage aussehen soll ? Bin noch newbie und so ein kompliziertes JOIN habe ich noch nie gemacht =( Geht es überhaupt mit JOIN ?
BOOK
--------------------------------
name | seller_id | buyer_id
--------------------------------
buch1 | 1 | 1
buch2 | 2 | 2
buch3 | 3 | null
buch4 | 4 | 3
SELLER
---------------------
id | person_id
---------------------
1 | 1
2 | 2
3 | 3
4 | 4
BUYER
---------------------
id | person_id
---------------------
1 | 5
2 | 6
3 | 7
PERSON
---------------------
person_id | name
---------------------
1 | person1
2 | person2
3 | person3
4 | person4
5 | person5
6 | person6
7 | person7
Ich möchte folgende Ergebnis mit JOIN (LEFT, RIGHT, usw) bekommen :
Ergebnis
---------------------------------------------------
Bookname | Sellername | Buyername
---------------------------------------------------
buch1 | person1 | person5
buch2 | person2 | person6
buch3 | person3 | null
buch4 | person4 | person7
Kann jemand mir verraten, wie die SQL-Anfrage aussehen soll ? Bin noch newbie und so ein kompliziertes JOIN habe ich noch nie gemacht =( Geht es überhaupt mit JOIN ?
Comment