Таблица с информацией о содержимом - content
:
+----------+-------------+-------------------+--------------------------------+
| (int) id | (int) title | (int) description | (string) tags |
+----------+-------------+-------------------+--------------------------------+
| 1 | 12 | 18 | super, awesome, must-see |
+-----------------------------------------------------------------------------+
| 4 | 25 | 26 | randomness, funny-stuff, cool |
+-----------------------------------------------------------------------------+
Таблица с информацией о переводе - translations
:
+-----------+---------------------------------+----------------+
| (int) tid | (text) value | (varchar) code |
+-----------+---------------------------------+----------------+
| 12 | Super-awesome-mustsee | en |
+--------------------------------------------------------------+
| 18 | <here would be the description> | en |
+--------------------------------------------------------------+
| <more translation data that is not necessary for this xmpl.> |
+--------------------------------------------------------------+
То, чего я хочу добиться, это заменить content.title
на translations.value
и то же самое для описания (больше / меньше данных для разных таблиц компонентов (content
)) , где content.title
соответствует translations.tid
, вроде:
+----------+-----------------------+---------------------------------+--------------------------------+
| (int) id | (text) title | (text) description | (string) tags |
+----------+-----------------------+---------------------------------+--------------------------------+
| 1 | Super-awesome-mustsee | <here would be the description> | super, awesome, must-see |
+-----------------------------------------------------------------------------------------------------+
Пока что мне нужно объединить данные перевода только для одного значения ... И да, присоединение не заменит. : |
SELECT `content` . * , `translations`.value
FROM `content`
JOIN `translations` ON `translations`.tid = `content`.title
WHERE `translations`.code = 'en'
Как мне этого добиться?
Заранее спасибо!