I need some help. I googled for solution, but I didn\'t found one.
I have three tables:
langs
(int) id | (varchar) language
1 | English
You are essentially looking at a pivot table. It Is doable, though the code is a bit cumbersome.
one source: http://www.artfulsoftware.com/infotree/queries.php#78
In the end though most any mysql solution will require either some wizardry with stored procedures or... hardcoding what languages you return.
Pivot tables are one area that mysql doesn't shine in.
SELECT CONCAT(
' SELECT `value`.`key_id`,'
, '`keys`.`keys`,'
, GROUP_CONCAT(
'GROUP_CONCAT(IF(`value`.`lang_id`=',id,',`value`.`value`,NULL))'
, ' AS `', REPLACE(language, '`', '``'), '`'
)
, ' FROM `keys` JOIN `value` ON `value`.`key_id` = `keys`.`id`'
, ' GROUP BY `value`.`key_id`'
)
INTO @sql
FROM `langs`;
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;