SQL - SELECT - FOREIGN KEY -


visitsexit              visitsentry               visitor idvisitsexit            idvisitsentry             idvisitor  idvisitsentry           idvisitante               visitor  idvisitor               visitor visitor dateexit timeexit 

i need select table visitsexit when bring visitsentry bring idvisitor , description of idvisitor (visitor).

a simple straightforward join give want:

select   t.idvisitor,   t.visitor,   t.dateexit,   t.timeext,   ... -- rest of columns want select  visitsexit       t inner join visitentry e on t.idvisitentry = e.visitentry inner join visitor    v on e.idvisitante  = v.idvisitor; 

you might need use left join if want include unmatched rows other tables. see post more information join types:


Comments