我有3张表,包括母亲,儿童和Junction这样的
母
Child(ChildName ZZZ应该有53个代码)
交界处
我想用母亲(至少2个)作为条件来了解他们的共同点 像
Select CodeChild
From Junction
Where CodeMother in ('02','03')
我期望得到的结果
答案 0 :(得分:0)
无法测试此
Select Junction.CodeChild, Child.ChildName From Junction
Inner Join Child On Junction.ChildCode = Child.CodeChild
Where Junction.CodeMother = CodeMother
答案 1 :(得分:0)
根据OP编辑 解决但欣赏任何更好的方法 由于母亲条件可以有1-4,查询取决于那个
例如
Select r.ChildName
From (Select j.CodeChild From Junct j Where j.CodeMother = 2)M1
inner join (Select j.CodeChild From Junct j Where j.CodeMother = 3)M2 On
M2.CodeChild = M1.CodeChild
//If More Mother Condition Just put inner join M3,M4 and So on Here
inner join Child r on M1.CodeChild = r.CodeChild