How to join 4 tables in one and show text instead of INT - INNER JOIN

-1

Hello, I know it's more or less like this in 2nd print and with the Inner join but I'm not getting it.

I'm using MySQL Workbench and more when I finish this I want to move to C #.

I have this question, I have already joined the 4 tables processos tarefas tipos tecnicos in the registos table.

Primary keys are the same as foreign keys, primary key of processos = id_processos , primary key of tarefas = id_tarefas , primary key of tipos = id_tipos , and primary key of tecnicos = id_tec .  The primary key of registos = id_registos .

Now I need help getting the value of the 4 tables into text instead of Int.

NOTE : If I need more information I give!

It's something like the 2nd Print!

Prints:

    
asked by anonymous 28.05.2018 / 17:42

2 answers

0

I did not really understand your question, but to show the relationship between the 4 different tables use the following syntax:

SELECT (tabela1.campo1, tabela2.campo2, ...)
FROM tabela1
INNER JOIN tabela2 on table1.campoRelação= table2.campoRelação
INNER JOIN tabela3 on table2.campoRelação= table3.campoRelação
INNER JOIN tabela4 on table3.campoRelação= table4.campoRelação
If you do the SELECT of the fields 'ID' will show the numbers, if you want to show the 'text' you should SELECT a field with the text content.

I hope I have helped.

    
28.05.2018 / 18:10
0

You only need to enter the description of the referencing table, so instead of p.id_processo you do p.descricao_processo

select p.descricao_processo
      ,t.descricao_tipo
      ,[...]
  from      processos p 
 inner join registros r on r.id_processos = r.id_registro
 inner join tipos     t on t.id_registro  = t.id_tipo

Edited

It would be +/- this here, now change the field names according to the fields in your table and also put the fields correctly in the joins if you need to ...

select r.id
      ,r.descricao_registro
      ,p.id
      ,p.descricao_processo
      ,t.id
      ,t.descricao_tipo
      ,ta.id
      ,ta.descricao_tarefa
      ,te.id
      ,t.nome_tecnico
  from      registros r 
 inner join processos p  on p.id_processos = r.id_processo
 inner join tipos     t  on t.id_tipo      = r.id_tipo
 inner join tarefas   ta on ta.id_tarefa   = r.id_tarefa
 inner join tecnicos  te on te.id_tec      = r.id_tec
    
28.05.2018 / 18:04