Brian, the online MySQL documentation is very complete and easy to read. That said, you do kind of have to know what you're looking for! I'm not sure what to recommend for a guide to beginning SQL, sorry, others may have some thoughts.
You are going down the right road with an aggregate function (grouping). What you want is slightly tricky, actually, but MySQL makes it easy with the GROUP_CONCAT function. http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html Here's a query you can run to get the output you specified: SELECT module_id AS "Module ID", GROUP_CONCAT(participant_answer ORDER BY question_id SEPARATOR ' ') AS "Participant Answers" FROM table_name WHERE email = '[EMAIL PROTECTED]' GROUP BY module_id ORDER BY module_id HTH, Dan On 3/7/07, Brian Menke <[EMAIL PROTECTED]> wrote:
MySQL 5.x I have a table that looks like this: module_id question_id email participant_answer 2 2.1 [EMAIL PROTECTED] a 2 2.2 [EMAIL PROTECTED] b 2 2.3 [EMAIL PROTECTED] c 2 2.4 [EMAIL PROTECTED] d 2 2.5 [EMAIL PROTECTED] e 1 1.1 [EMAIL PROTECTED] a 1 1.2 [EMAIL PROTECTED] c 1 1.3 [EMAIL PROTECTED] d 1 1.4 [EMAIL PROTECTED] b 1 1.5 [EMAIL PROTECTED] d 5 5.1 [EMAIL PROTECTED] a 5 5.2 [EMAIL PROTECTED] c 5 5.3 [EMAIL PROTECTED] d 5 5.4 [EMAIL PROTECTED] b 5 5.5 [EMAIL PROTECTED] d Being an SQL novice, whenever I run any kind of selects, for example select * from table_name where email = '[EMAIL PROTECTED]' I get the results in rows just like you would see above, which is what I would expect. What I really need is this format Module ID Participants Answers 1 a b c d e 2 a b c d e 5 a c d b d Instead of 1 row for each listed module id. I tried grouping by module_id such as select * from table_name where email = '[EMAIL PROTECTED]' group by module_id But that ended up just giving me 1 row with one answer. I think the solution is grouping somehow, but I'm not quite experienced enough to put it all together. Any help is greatly appreciated, even if it's just a pointer to some mysql docs. Thanks in advance! -Brian Menke -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]