There is the first table (ocenka) which contains the ID of the employee and his ID. There is a second table (sotr) which contains the names of these people. This is what I did, but I do not understand how to expand to the withdrawal of the Surname and the employee and his manager.

SELECT ocenka.id_sotr, sotr.fio FROM ocenka, sotr Where ocenka.id_sotr=sotr.id 

1 answer 1

I do not know how you have a field id id called in the table ocenka, but if it was called id_rucovoditel, then so

 SELECT ocenka.id_sotr as "ИД" ,sotrS.fio as "фИО сотрудика" ,sotrR.fio as "ФИО руководителя" FROM ocenka oc join sotr sotrS on oc.id_sotr=sotrS.id join sotr sotrR on oc.id_rucovoditel=sotrR.id 

But seriously, you need to read sql for dummies))) since this is the most basic question)).

  • Cannot work with your request. SELECT dekad_ocenka.id_sotr, sotr_S.fio as "ФИО_С", dekad_dolgnost.name, sotr_R.fio AS "ФИО Р", dekad_ocenka.ocen_itog FROM dekad_ocenka, dekad_dolgnost, JOIN sotr sotr_S on oc.id_sotr=sotr_S.id JOIN sotr sotr_R on oc.id_ruk=sotr_R.id - maix
  • swear right syntax to use near 'JOIN sotr sotr_S on oc.id_sotr=sotr_S.id JOIN sotr sotr_R on oc.id_ruk=sotr_R.id' at line 1 - maix
  • @maix Take the request unchanged, as in the answer. Copy in a notebook or there in a Word. Next, replace and search for one by one - the names of the tables, the names of the fields ... then (if you don’t mess up again) succeed. - Akina
  • And yet - in the original question was not half a word about the post. Therefore, it is incorrect to nod at problems in an unanswered task. - Akina
  • @heff issues like this. SELECT dekad_ocenka.id_sotr as "ID", sotrS.fio as "FIO sotrudika", sotrR.fio as "FIO of the head" FROM id LIMIT 0, 25 Answer MySQL: Documentation # 1054 - Unknown column 'dekad_ocenka.id_sotr' in 'field list' - maix