0

I have 3 tables like this.

Person

ID | FirstName | LastName | 
----------------------------
1  | Tim       | yank
2  | Nick      | Thomas
3  | Leo       | Peter
4  | Frank     | Thomas
5  | George    | Hick
6  | Joe       | Moses

Hobbies_person

HobbyID | personID |
----------------------------
1       | 1 
3       | 1
4       | 1
2       | 2
2       | 4
3       | 3
4       | 2
4       | 5
2       | 5
1       | 6

Hobbies :

ID   | Name
------------
1    | Soccer
2    | Fishing
3    | Hiking
4    | Painting

I want to do a query like when i give a person id it should give me first name last name & hobby. If a person has more than 1 hobby (like personid 1) result should be like Tim, Yank, (1, 3, 4)--> all hobbies as a string seperated by a ,

Not able to do the hobbies concatenation.

eshirvana
  • 23,227
  • 3
  • 22
  • 38
vishal
  • 11
  • 2

0 Answers0