Flaw表的列:
FlawID ,StartPoleCode , EndPoleCode, StartLineCode, EndLineCode,
注意start end是个范围,比如start=2,end=5,则2345都在此范围里ScoutLine表的列
ID Code ScoutTaskID ScoutPole表的列
ID Code ScoutLineID 关系:ScoutPole 与 ScoutLine 关联
Flaw与另外两个表关联
求与ScoutTaskID =‘123’ 关联的flaw表的所有行
FlawID ,StartPoleCode , EndPoleCode, StartLineCode, EndLineCode,
注意start end是个范围,比如start=2,end=5,则2345都在此范围里ScoutLine表的列
ID Code ScoutTaskID ScoutPole表的列
ID Code ScoutLineID 关系:ScoutPole 与 ScoutLine 关联
Flaw与另外两个表关联
求与ScoutTaskID =‘123’ 关联的flaw表的所有行
from Flaw a,(
select id from ScoutLine where ScoutTaskID =‘123’
) b
where b.id >= a.StartLineCode and b.id <= a.endLineCode
from flaw a,ScoutLine b,ScoutPole c
where b.ScoutTaskID =‘123’and b.ID=c.ID and a.FlawID=b.id
不知道你的三个表是用什么字段来关联的,我用的是ID字段
FlawID ,StartPoleCode , EndPoleCode, StartPoleName, EndPoleName, LineCode,LineName
注意start end是个范围,比如start=2,end=5,则2345都在此范围里ScoutLine表的列
ID Code Name ScoutTaskID ScoutPole表的列
ID Code Name ScoutLineID 关系:ScoutPole 与 ScoutLine 关联
Flaw与另外两个表关联
求与ScoutTaskID =‘123’ 关联的flaw表的所有行这样是该怎么做
Select f.*
from Flaw f,
(
select l.Code lCode,p.Code pCode
from ScoutLine l, ScoutPole p
where l.ScoutTaskID = '123' and l.ID = p.ScoutLineID
) a
where a.pCode >= f.StartPoleCode and a.pCode <= f.EndPoleCode and a.lCode = f.LineCode
看着写了一下,不知道理解对了没有
Flaw表冗余太多 -_-