У меня есть две таблицы:
CREATE TABLE sections (id int, section_name varchar(16), section_title int, section_description int);
INSERT INTO sections VALUES(1, 'index', 1, 2);
INSERT INTO sections VALUES(2, 'contact', 3, 4);
CREATE TABLE texts (id int, text_value varchar(64), text_language varchar(2), text_link int);
INSERT INTO texts VALUES(1, 'Home', 'en', 1);
INSERT INTO texts VALUES(2, 'Inicio', 'es', 1);
INSERT INTO texts VALUES(3, 'Welcome', 'en', 2);
INSERT INTO texts VALUES(4, 'Bienvenidos', 'es', 2);
INSERT INTO texts VALUES(5, 'Contact', 'en', 3);
INSERT INTO texts VALUES(6, 'Contacto', 'es', 3);
INSERT INTO texts VALUES(7, 'Contact Us', 'en', 4);
INSERT INTO texts VALUES(8, 'Contactenos', 'es', 4);
Я новичок с запросами, и я не знаю, что делать дальше:
SELECT `sections`.`section_title`
, `sections`.`section_description`
FROM `sections`
INNER JOIN `texts`
ON (`sections`.`section_title` = `texts`.`text_link`) AND (`sections`.`section_description` = `texts`.`text_link`)
WHERE `sections`.`section_name` = 'index' AND `texts`.`text_language` = 'en'
;
MySQL вернул пустой набор результатов: (
Я ожидаю получить используя sections
. section_name
= 'index' и texts
. text_language
= 'en':
section_title = 'Home'
section_description = 'Welcome'
или с помощью sections
. section_name
= 'contact' и texts
. text_language
= 'es':
section_title = 'Contacto'
section_description = 'Contactenos'