By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table `table1` (
id int,
fio varchar(30)
);
create table `table2` (
name int,
famyli int,
otchestvo varchar(30)
);
insert into `table1` values (12, 'Иванов'),(14, 'Иван');
insert into `table2` values (14, 12, 'Иванович');
SELECT CONCAT(table1.fio, ' ', table3.fio, ' ', table2.otchestvo) as fullname
FROM table1, table2, table1 AS table3
WHERE table1.id = table2.name AND table3.id = table2.famyli
fullname |
---|
Иван Иванов Иванович |