SQL select one thing from two different tables in the same query

0

Good, I have two tables, one is called PERSONAL and the other TASK, and I do not know if it is possible through the JOIN operator to select the field "name" of the PERSONAL table and the "description" field of the TASK table that has a certain id. The composition of the tables would be:

PERSONAL

  • Name
  • DNI
  • Age

TASK

  • Id
  • DNI_personnel
  • Description

The relationship between both is ID that is the key that propagates from one to another because it is a 1: N relationship I would like the query to return tuples in plan: name1, description1, name2, description2, ... there are .. I think it is necessary to use JOIN and the condition of where would be id = to a value, but I do not know how to put SELECT of both fields being discrete tables

    
asked by midlab 23.02.2017 в 20:02
source

2 answers

3

Try with:

SELECT P.Nombre
    ,P.DNI
    ,T.Descripcion
FROM Persona P
INNER JOIN Tarea T ON P.DNI = T.DNI_persona
WHERE T.Id = IdDeTarea

In this page you can find the official documentation to formulate queries and its syntax

    
answered by 23.02.2017 / 20:07
source
-1
Select 
    tabla.campo, tabla2.campo 
inner join 
    tabla2 on table.campo = table2.campo 
where 
    table.campo=valor;
    
answered by 24.02.2017 в 01:30