tags:

views:

103

answers:

2

I have the following structure:
main: id | meta_data
sub: main_id | another_table_id
main is connected to sub in a one to many.

I wish to get back my result as one record which will look like:
[main_id] [meta_data] [another_table_id,another_table_id,another_table_id]

Is it possible in MySql without using GROUP BY?

+1  A: 

Are you looking for MySqls GROUP_CONCAT function.

zodeus
as stated in the question, without using GROUP BY ...
Itay Moav
Then the answer is no.
zodeus
GROUP_CONCAT is the MySQL-approved way to break the relational model. If it can't do what you want, then you probably need to rethink your use of a relational database in general.
kquinn
+2  A: 

I would say that the natural way to do this is using GROUP_CONCAT, and that it would not be possible to do this without GROUP BY.

The GROUP BY, it appears, is the correct way to do what is wanted.

MySQL can do this join, complete with GROUP BY, without a temporary table or filesort, if that is what is concerning you about GROUP BY. You will need to ensure that there is an index which matches the GROUP BY columns.

thomasrutter