How to merge 4 tables into one and show text instead of INT - INNER JOIN

Asked

Viewed 305 times

-1

Hi, I know it’s kind of like this in the second print and with Inner Jay but I’m not getting it.

I’m using Mysql Workbench and more when I finish this I want to go to C#.

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

Primary key equals foreign key, primary key processos = id_processos, the primary key to tarefas = id_tarefas , the primary key to tipos = id_tipos and the primary key of tecnicos = id_tec. The primary key of registos = id_registos.

Now need help to put the value of the 4 tables in text instead of Int.

NOTE: If you need more information!

It’s something like the 2nd Print!

Prints:

Valores base de dados É algo deste genero

2 answers

0

You just need to enter the description of the referent table, so instead 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 name of the fields according to the fields of your table and also put the fields correctly in the joins if you need...

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
  • I need to use the 4 tables, techniques, processes, types and tasks!

  • I guess instead of showing the ID as 1 or 2 (the ID value in your table) for example I chose Goodbye which has the value 3 instead of showing 3 show Goodbye

  • Only do the Inner Join with its 4 tables as you have done with the table RECORDS and TYPES, and instead of bringing the field ID of these tables, you bring the field description of each table, which would be the field that has the "Goodbye" as in your example

  • my brain is bugged and I’m not able to do... has Discord?

  • I don’t have Discord, check the edition of my responsta!

  • What is Description and where to create that column?

  • Dude, please study something about database before you ask questions, you need to know at least the basic concept! Below I leave some links: link link

  • I’ve done everything on the database, only those who look at what you said don’t understand anything, try to be more specific. I just asked if the descriptions were a new column.

  • Take this two columns as an example te.id, te.nome_tecnico.... [te.id - Column id of the TECNICOS table; te.technical name_name - Column that has the technical name or description of the TECNICOS table;] Logo, if your TECNICOS table has the columns [ID | Name | Sex], you would do te.ID, te.Nome... Clearer than that impossible.

  • Voce didn’t realize what I wanted initially, but thanks for the help has already been solved.

Show 5 more comments

0


I didn’t quite understand your question, but to show the relationship between the different 4 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

Note: If you select the ID fields you will display the numbers, if you want to display the text you should select a field with the text content.

I hope I’ve helped.

  • I need to use the 4 tables, techniques, processes, types and tasks!

  • I guess instead of showing the ID as 1 or 2 (the ID value in your table) for example I chose Goodbye which has the value 3 instead of showing 3 show Goodbye

  • As I wrote in the note, what will show depends on what you put inside the SELECT parentheses, if you put the ID, it will show the ID, if you put the field that contains the "Goodbye", it will trim that goodbye instead of the ID.

  • my brain is bugged and I’m not able to do... has Discord?

  • No... I’m also new to this, which is the name of your field that contains the so-called "Goodbye"?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.