我有2个表:表一:laneparameter 字段:expwayname,stationid,stationname,laneid,processtime,blackver(黑名单),grayver(灰名单)
表2:listdownresult 字段:stationid,tabletype,stationname,downloadtime,downversion(说明:tabletype=1表示黑名单=2表示灰名单)
要求:表一的stationid里面有多个laneid 需要通过2个表来查询出2个表中当前正在使用的版本不相同的打印在页面上,我只能一个expwayname,stationname来查出来,但是要的是一次能查出所有的怎么解决,谢谢!
这是我查一个expwayname下的stationname的不同的版本数据,哪位大哥大姐帮我解决下怎么查询出所有的! select distinct DBMID.listdownresult200904.downversion,dbetc.laneparameter200904.laneid,dbetc.laneparameter200904.stationid,dbetc.laneparameter200904.stationname,dbetc.laneparameter200904.expwayname ,dbetc.laneparameter200904.blackver from dbetc.laneparameter200904 ,DBMID.listdownresult200904 where dbetc.laneparameter200904.stationID='2110004' and DBMID.listdownresult200904.stationID ='2110004' and dbetc.laneparameter200904.processtime = (select max(processtime) from dbetc.laneparameter200904 where stationid='2110004') and DBMID.listdownresult200904.downversion =(select downversion from dbmid.listdownresult200904 where tabletype=1 and stationid='2110004' and downloadtime= (select max(downloadtime) from dbmid.listdownresult200904 where stationid='2110004'and tabletype=1)) and dbetc.laneparameter200904.blackver
!=dbmid.listdownresult200904.downversion
表2:listdownresult 字段:stationid,tabletype,stationname,downloadtime,downversion(说明:tabletype=1表示黑名单=2表示灰名单)
要求:表一的stationid里面有多个laneid 需要通过2个表来查询出2个表中当前正在使用的版本不相同的打印在页面上,我只能一个expwayname,stationname来查出来,但是要的是一次能查出所有的怎么解决,谢谢!
这是我查一个expwayname下的stationname的不同的版本数据,哪位大哥大姐帮我解决下怎么查询出所有的! select distinct DBMID.listdownresult200904.downversion,dbetc.laneparameter200904.laneid,dbetc.laneparameter200904.stationid,dbetc.laneparameter200904.stationname,dbetc.laneparameter200904.expwayname ,dbetc.laneparameter200904.blackver from dbetc.laneparameter200904 ,DBMID.listdownresult200904 where dbetc.laneparameter200904.stationID='2110004' and DBMID.listdownresult200904.stationID ='2110004' and dbetc.laneparameter200904.processtime = (select max(processtime) from dbetc.laneparameter200904 where stationid='2110004') and DBMID.listdownresult200904.downversion =(select downversion from dbmid.listdownresult200904 where tabletype=1 and stationid='2110004' and downloadtime= (select max(downloadtime) from dbmid.listdownresult200904 where stationid='2110004'and tabletype=1)) and dbetc.laneparameter200904.blackver
!=dbmid.listdownresult200904.downversion
a.laneid,
a.stationid,
a.stationname,
a.expwayname,
a.blackver
FROM dbetc.laneparameter200904 a, DBMID.listdownresult200904 b
WHERE b.stationID = a.stationID
AND a.processtime = (SELECT MAX(processtime)
FROM dbetc.laneparameter200904
WHERE stationid = a.stationID)
AND b.downversion = (SELECT MAX(downversion) KEEP(dense_rank LAST ORDER BY downloadtime)
FROM dbmid.listdownresult200904
WHERE stationid = a.stationID
AND tabletype = 1)
AND a.blackver != b.downversion
AND a.stationID = '2110004'
你把上面那条sql的最后一行注释掉就好了