sql - Use the foreign key that a query selects to get data within the same query -


i have issue query trying build. idea have 3 tables 2 have foreign keys. want make query selects foreign key table , uses same key data key b.

so this:

select      id, foreignkey1       tablea      (select id tableb id = foreignkey1); 

but somehow not able or find documentation it.

this simple inner join:

select      *        tablea  inner join  tableb  b   on  a.foreignkey1 = b.id 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -