MySQL Forums
Forum List  »  Newbie

Query question
Posted by: adriano devide
Date: February 07, 2017 06:21PM

I have tried several Queries but could not get what I am expecting.
My problem is, I have 2 tables 1 and 2 like below

Table 1
ID |name |surname |dob
1 |Smith |John |2000-01-06
2 |Doe |Joe |1958-08-25
3 |Meyer |Holly |1960-05-09


Table2
ID |profile-key |profile.value
1 |profile.tel |123 453 456
1 |profile.mobile |235 445 23
1 |profile.address |22, Church Street
1 |profile.city |Dodge city
2 |profile.tel |565 5654 32
2 |profile.mobile |2528 25 1213
2 |profile.address |1234, 6th Avenue
2 |profile.city |New London
3 |profile.tel |457 578 45
3 |profile.mobile |121 545 88
3 |profile.address |3, North Street
3 |profile.city |Chicago

What I am trying to get is the following

Table 3
ID |name |surname |dob |profile.tel |profile.mobile |profile.address |profile.city
1 |Smith |John |2000-01-06 |123 453 456 |235 445 23 |22, Church Street |Dodge city
2 |Doe |Joe |1958-08-25 |565 5654 32 |2528 25 1213 |1234, 6th Avenue |New London
3 |Meyer |Holly |1960-05-09 |457 578 45 |121 545 88 |3, North Street |Chicago


My best guess was following:

select
table2.ID, table2.profile_key, table2.profile_value,
table1.name,
table1.username,
table1.dob
from
table1
inner join table2
on
table1.ID = table2.ID


without the expected results.

Can anyone help me here?

Options: ReplyQuote


Subject
Written By
Posted
Query question
February 07, 2017 06:21PM
February 07, 2017 07:25PM
February 08, 2017 03:59AM
February 08, 2017 01:04PM
February 09, 2017 12:24PM
February 09, 2017 12:30PM
February 09, 2017 12:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.