Help with fun SQL; return devices, first dn and that dns route partition...

Version 1
    This document was generated from CDN thread

    Created by: Jeff Garner on 14-01-2010 08:28:32 PM
     
    Im trying toget a single sql query to return devices, the DN on line 1 and that DNs route partition...
     
    I get the error : "An ON clause has an invalid table reference"  So it doesnt like my second inner join
     
     
    sqlquery="SELECT FIRST 50 D.Name as name, D.description as desc, NP.dnorpattern as dn, rp.name as rp, dp.name as dpool FROM NumPlan NP, DeviceNumPlanMap DNPMap, Device D inner join devicepool dp on dp.pkid=d.fkdevicepool inner join routepartition rp on rp.name=NP.fkroutepartition where DNPMap.fkNumPlan = NP.pkid AND D.pkid = DNPMap.fkDevice and DNPMap.numplanindex=1 and (D.tkclass='1' or D.tkclass = '2'or D.tkclass = '10')";
     
    Any suggestions?
     
     
    Thanks