sql one to many including itself? -


struggling 1 many includes master record without having add detail record references itself?

select * master m inner join detail d on d.id2 = m.id d.id1 = 1 

this return

2,john,1,2 4,nancy,1,4 

how return

1,jim,nul,nul 

if add 1,1 record below detail works, hoping around that.

master

1,jim 2,john 3,fred 4,nancy 5,jen 

detail

1,2 1,4 3,5 

thanks glenn

i think want more complicated on expression:

select * master m inner join      detail d      on d.id2 = m.id or d.id1 = m.id d.id1 = 1; 

you write as:

     on m.id in (d.id1, d.id2) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -