ich eine Datenbankstruktur wie dieses:mysql Übersetzungstabellen mit fehlenden Sprachausweich
Länder
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
`is_active` tinyint(1) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_5D66EBAD77153098` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Länder Sprache
CREATE TABLE IF NOT EXISTS `country_languages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`language_id` int(11) DEFAULT NULL,
`country_id` int(11) DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `IDX_1532561982F1BAF4` (`language_id`),
KEY `IDX_15325619F92F3E70` (`country_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Sprache
CREATE TABLE IF NOT EXISTS `languages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`iso` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '1',
`is_primary` tinyint(1) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_A0D153795E237E06` (`name`),
UNIQUE KEY `UNIQ_A0D1537961587F41` (`iso`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
und die Daten für die Tabelle Sprachen:
id name iso
----------------------
1 English en
2 German de
3 Italian it
Und Land Tabelle:
id code
----------------
1 ie
und Tisch Land Sprachen
id country_id language_id name
----------------------------------------------
1 1 1 Ireland in English
2 1 2 Ireland in German
Ich versuche eine Abfrage zu schreiben, die das folgende Ergebnis zurückgibt, um es anzuzeigen. (Wenn möglich)
(Language) (Country name)
English Ireland in English
German Ireland in German
Italian #NULL OR EMPTY STRING
Und zweitens Ich versuche zu verstehen, wenn es möglich ist, Englisch als Standardsprache zum Beispiel zu setzen und, wenn Inhalte für die Sprache mit der ID 3 (Italienisch) nicht vorhanden ist sollte der Standardrückfall in als Ergebnis wie folgt aus:
(Language) (Country name)
English Ireland in English
German Ireland in German
Italian Ireland in English #please note language id is 3 -> Italian.
Ich bin verwirrt von Ihrem Beispiel. die "country languages table", ist das eigentlich eine Tabelle oder ist das Ergebnis einer Abfrage? Auch die Abfragen direkt danach, es ist einfach nicht klar was "id" bedeuten soll und wie diese Daten zusammen kommen ... – Jakumi
@Jakumi Ich habe meine Frage aktualisiert. Ich hoffe jetzt ist es klarer –