Table 1 : member
id_member | id_city | id_major | id_faculty | name | phone |
mbr0001 | 1 | 1 | 1 | Rafi Hajid | 0812234586 |
mbr0002 | 1 | 2 | 2 | Almira | 08775123495 |
Table 2:City
id_city | name |
1 | Surabaya |
2 | Kediri |
Table 3: Major
id_major | name |
1 | S1 SI |
2 | D3 SI |
Table 4: Faculty
id_faculty | name |
1 | Science and Technology |
2 | Vocational |
The Information that I needed from those tables were name of the member, phone's Nr., City's name, Major's name and Faculty's name.
This is the SQL to retrieve those information:
select m.name, m.phone, c.name as city, mj.name as major, f.name as faculty
from member as m
join city as c on m.id_city = c.id_city
join major as mj on m.id_major = mj.id_major
join faculty as f on m.id_faculty = f.id_faculty
The result of the query would be:
name | phone | city | major | faculty |
Rafi Hajid | 0812234586 | Surabaya | S1 SI | Science and Technology |
Almira | 08775123495 | Surabaya | D3 SI | Vocational |
Hope this can help you, somehow....
Tidak ada komentar:
Posting Komentar