Nested inner joins with select sql access -
i have 2 similar questions , think this similar need can't figure out in cases
1. have 3 tables field did
connects fd
d
, dm
d
:
`fd`: `fid`, `did` (`fid` , `did` create pk together) `d`: `did` (pk), `data` `dm`: `did`, `type` (`did` , `type` create pk together)
i looking way find records in d
fulfill fid = 'condition1
, type = 'condition2'
right have solved in following way (it works, ugly have nicer solution)
q1: select did fd fid = 'condition1' q2: select did dm type = 'condition2' select * d d.did in (select q1.did q1 inner join q2 on q1.did = q2.did)
2. have 3 tables again. mid
connects tm
m
, typeid
connects m
types
:
<br> `tm`: `tmid`, `mid` (pk together) `m`: `mid` (pk), `mnum`, `typeid` `types`: `typeid` (pk), `type`
so here looking way select type
types
, mnum
m
when have condition on tmid
the following not correct because want able select mnum
, type
@ same time like: select types.type, m.mnum ....
. want these selections
q1: select mid tm tmid = 'condition3' q2: select mnum, typeid m m.mid in q1 q3: select type types typeid in q2
for first query have merge conditions 1 single query:
select did fd fid = 'condition1' , type='condition2'
for second query, can join 3 tables , apply condition:
select types.type tm inner join (m inner join types on m.typeid = types.typeid) on tm.mid = m.mid tm.tmid='condition3';
Comments
Post a Comment