I have two tables. One table with static information (userid, username, dob, village). The second table with variable information (userid, favourite_food). One user can have several favourite foods.
I want to join the two tables to output without repeating the record. The favourite foods should be in colums but the numbers can be varied for each user.
Example Table 1
userid usernames dob village
2001 wallace 1963 olu
2002 John 1975 remba
2003 Maurice 1954 goro
2004 Patrick 1932 goro
2005 Emma 2000 chula
2006 Mary 1989 remba
2007 Anne 2001 sakwa
2008 Moses 1994 remba
2009 Agatha 1956 sori
Table 2
userid favourite_food
2001 fries
2002 rice
2003 potatoes
2004 chicken
2004 beef
2005 mutton
2001 pork
2003 chapati
2004 dhal
2006 fries
2007 carrot
2008 lamb
2009 bread
2009 corn
Expected output
userid usernames dob village favouritef_food1 favourite_fod2 favourite_food3
2001 wallace 1963 olu freis pork
2002 John 1975 remba rice
2003 Maurice 1954 goro potatoes chapati
2004 Patrick 1932 goro chicken beef dhal
2005 Emma 2000 chula mutton
2006 Mary 1989 remba fries
2007 Anne 2001 sakwa carrot
2008 Moses 1994 remba lamb
2009 Agatha 1956 sori bread corn
Note: There is no prior way to know the number of favourite foods one can have and there is no max. For each additional, there should be a column in the output.
How do i do this?