MySQL Joining three tables

Posted by text on Stack Overflow See other posts from Stack Overflow or by text
Published on 2010-05-21T12:17:23Z Indexed on 2010/05/21 12:20 UTC
Read the original article Hit count: 152

Filed under:
|

I am doing a query with three tables, the problem was one table has many occurrences of id of another.

sample data:

users: id

answers: 
id:1
user_answer :1
id:1
user_answer :2
id:1
user_answer :3

Questions: 
id:1
answers :answer description
id:2
answers :answer description
id:3
answers :answer description

How can I get all user information and all answer and its description, I used GROUP by user.id but it only returns only one answer.

I want to return something like this list all of users answer:

Name         Q1          Q2    
USERNAME    ans1,ans2    ans1,ans2             comma separated description of answer here

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql