bigdspbandj Posted January 24, 2008 Share Posted January 24, 2008 Is there a query (joins, or nested query) that can merge multiple results into a single row? There are multiple records from t2 that match up with t1 via t1's primary key. Example: t1: iddescription 1apples 2oranges t2: idt1_idlabeldate 131added2008-01-23 141modified2008-01-23 132added2008-01-24 142modified2008-01-24 The only solutions I can think of are creating a temp table or to mess around with the loop to concat. a string with the data, but I am not sure which is best or of there is a more elegant solution. Thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted January 24, 2008 Share Posted January 24, 2008 You mean GROUP_CONCAT()? What is the output you'd like to see/ Quote Link to comment Share on other sites More sharing options...
bigdspbandj Posted January 24, 2008 Author Share Posted January 24, 2008 It wouldn't let me modify the original post so here is the table again. Example: t1: iddescription 1apples 2oranges t2: idt1_idlabeldate 131added2008-01-23 141modified2008-01-23 132added2008-01-24 142modified2008-01-24 The result I would like to see is as follows: iddescriptiondate_addeddate_modified 1apples2008-01-232008-01-23 2oranges2008-01-242008-01-24 Quote Link to comment Share on other sites More sharing options...
fenway Posted January 25, 2008 Share Posted January 25, 2008 You can do this with two left joins... but only if you know the fields in advance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.