0

I have 2 table :

   ----------------------------
   | Id | Name   | Surname   |
   ---------------------------
   | 1  | John   | Smith     |
   | 2  | Alex   | Stone     |
   ---------------------------

    -----------------------
   | Id_User   | Books     |  
   ------------------------
   | 1         | LOTR      |     
   | 1         | GOT       |        
   | 1         | HP        |    
   | 2         | Sharlock H|
   | 2         | Peter Pan |
   -------------------------

The Id_User Column is foreign key. I want to take all the books in the second table and show them like this.

   ------------------------------------------------
   | Id | Name  | Surname | First | Second | Third |
   ------------------------------------------------
   | 1  | John  | Smith   |LOTR   |GOT     |HP     |
   | 2  | Alex  | Stone   |Sharlock|Peter P| null     |
   -------------------------------------------------

There could be more or less book and thats because We can put a max book limits like 5 to make it more clear. Is there any way to do it?

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
ssvt
  • 11
  • 1

0 Answers0