MYSQL- orientation about an inner join

0

I have a table (bd mysql) where I store several IDs (foreign keys) and now I need to show the data linked to those IDs according to a specific value, which is an identifier.

For example, I should get something like this:

001|identificada|soporte terreno|juanito perez|registrada|2018-04-20|detalle de incidencia

and in my table of inidence, the structure is more or less like this:

id_incidencia, id_tipo,_id_soporte,id_funcionario....

I must use inner join, that I have clear, the issue is that I do not know how to do the query, I have so far this:

SELECT
id_incidencia.tbl_incidencias,
fecha_registro.tbl_incidencias,
detalle_incidencia.tbl_incidencias,
identificacion_categoria.tbl_categoria_incidencia,

FROM
tbl_incidencias
INNER JOIN tbl_categoria_incidencia.id_categoria ON = tbl_incidencias.id_categoria
WHERE
tbl_incidencias.id_registro=1

My request is if you can help me a bit in that I'm wrong, or how I could handle the consultation ...

    
asked by Nicolas Ezequiel Almonacid 20.04.2018 в 18:48
source

2 answers

1

Your query is in reverse. It should be like this:

SELECT
tbl_incidencias.id_incidencia,
tbl_incidencias.fecha_registro,
tbl_incidencias.detalle_incidencia,
tbl_categoria_incidencia.identificacion_categoria,

FROM
tbl_incidencias
INNER JOIN tbl_categoria_incidencia ON tbl_categoria_incidencia.identificacion_categoria= 
tbl_incidencias.id_categoria
WHERE
tbl_incidencias.id_registro=1

You can see more on the MySql Documentation

    
answered by 20.04.2018 в 18:50
0

Achieve this:

SELECT 
inc.id_incidencia,
inc.fecha_registro,
ingr.identificacion_metodo,
est.identificacion_estado,
tip.identificacion_solicitud,
niv.identificacion_nivel,
fun.nombre_funcionario,
func.id_registro,
inc.detalle_incidencia

FROM tbl_incidencias inc 
INNER JOIN tbl_niveles_incidencia niv ON inc.id_nivel=niv.id_nivel/* verifica el nivel de la incidencia*/
INNER JOIN tbl_tipo_solicitud tip ON inc.id_tipo_solicitud=tip.id_tipo_solicitud/*verifica el tipo de solicitud*/
INNER JOIN tbl_funcionario_soporte fun ON inc.id_registro_soporte=fun.id_registro_soporte
INNER JOIN tbl_estados_incidencia est ON inc.id_estado=est.id_estado
INNER JOIN tbl_metodos_ingreso_incidencia ingr ON inc.id_metodo_ingreso=ingr.id_metodo_ingreso

It brings me the fields ok, but I have to add a where that brings me all the records according to the id_registro , there I get lost ...

    
answered by 20.04.2018 в 21:03