I created these tables:
create table documents (iddocument int, name varchar(30)); create table languages (idlang char(2), lang_name varchar(30)); create table document_languages (iddocument int, idlang char(2));
Create a basic query using the GROUP_CONCAT function to get the data conversion results:
select d.iddocument, group_concat(dl.idlang) from documents d, document_languages dl where d.iddocument = dl.iddocument group by d.iddocument;
And finally, set the number of documents with the LIMIT parameter:
select d.iddocument, group_concat(dl.idlang) from documents d, document_languages dl where d.iddocument = dl.iddocument group by d.iddocument limit 10;
You can learn more about GROUP_CONCAT here: http://dev.mysql.com/doc/refman/5.0/es/group-by-functions.html
source share