sql - How to properly join these selects? -



sql - How to properly join these selects? -

[1] select x.id somwhere x.location = _stringreturnedfromc#_ // need id table, know strin: location (from c#) [2] select y.nameid _relationbetweenxandy_ xy xy.id = [1] // utilize id found in [1] [3] select z.name z z.nameid = [2] // utilize id found in [2]

now how can tell select [2] looking xy.id = result select [1]

and select [3] i'm looking name of guy id z.nameid

i asked question here far i'm concerned question beyond saving.

z table: z.name, z.nameid y table: y.place, y.placeid // fixed, used placeid, inface string: place x table: x.name, x.placeid

if have same name, foreign keys (nameid, placeid)

this how actual code looks like:

select * angajati bring together distribuire d on d.locatie = 'oradea' // need d.distribuireid while know d.locatie (d.location). how ? bring together angajari on d.distribuireid = an.distribuireid

thus

select * tablex x bring together tabley y on x.placeid = y.placeid bring together tablez z on y.nameid = z.nameid

does not work because don't know y.placeid, know y.place

last edit

sorry if getting long. here how should (what mean that, if syntax won't work, logic) need syntax this!

select d.distribuireid distribuire d d.locatie = 'oradea' bring together angajari on an.distribuireid = d.distribuireid /*here i'd need an.angajatid locationid selected*/ bring together angajati on a.angajatid = an.angajatid

looks need inner joins:

select * tablex x bring together tabley y on x.placeid = y.placeid bring together tablez z on y.nameid = z.nameid

hope helps.

-edit -- why won't work? sorry if i'm not understanding question...

select d.distribuireid distribuire d bring together angajari on an.distribuireid = d.distribuireid bring together angajati on a.angajatid = an.angajatid d.locatie = 'oradea'

good luck.

sql sql-server-2012

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -