I have three mysql tables:
user
Code: Select all
Type Collatie Attributen Leeg Standaardwaarde Extra Actie
1 user_id int(11) Nee 0
2 user_email varchar(255) utf8_general_ci Nee Geen
3 user_password varchar(255) utf8_general_ci Nee Geen
4 user_firstname text utf8_general_ci Nee Geen
5 user_lastname text utf8_general_ci Nee Geen
Code: Select all
Type Collatie Attributen Leeg
1 group_id int(11) Nee Geen
2 club_id int(11) Nee Geen
3 mem_id int(11) Nee Geen
Code: Select all
club
Type Collatie Attributen
1 club_id int(11)
2 club_name varchar(50)
I try to find out how i can add the club_name (from the third table) with the user_firstname, user_lastname.
I wanna use with this code, I understand it not quite & keep on learning, and it is resulted a Select like this.
Code: Select all
$sql = "SELECT A.`user_firstname` , A.`user_lastname` , B.`mem_id` , B.`club_id` , C.`club_name` , C.`club_id`
FROM `user`AS A
INNER JOIN `group` AS B
ON B.`mem_id` = A.`user_id`
INNER JOIN `club` AS C
ON B.`club_id` = C.`club_name` ";