sql - INNER JOIN in a long query? -


i landed @ new job , there´s report i´m asked show information stored in table, need enhance existing query developed left company.

the query long , i´m not getting should insert inner join clause retrieve information need.

this original code:

    select toollists.ident,        toollists.descript tldescript,        toollists.materialnr,        toollists.order,        toollists.who,        toollists.ncp,        toollists.rem tlrem,        toollists.mdate,        toollists.tdate,        toollists.gdate,        toollist.t,        machines.name machinename,        machines.trelation,        toollist.d,        toollist.h,        toollist.pos toollistpos,        toollist.rem toollistrem,        toollist.how toollisthow,        tools.nr,        tools.z1,        tools.drawing,        tools.x1,        tools.sort,        tools.design,        tools.descript,        tools.rem toolrem,        toolparts.pos toolpartpos,        toolparts.nbr,        toolparts.how,        parts.unr,        parts.mid,        parts.descript,        parts.sort,        parts.design,        parts.urem,        parts.dmc,        parts.clength,        parts.cmainarc,        parts.cradius,        parts.uactiv,        matclasses.dmc,        matclasses.description,        matclasses.quality,        notetoollists.notetext parts inner join ( (machines               right join ( (matclasses                             right join (notetoollists                                         right join (materials                                                     right join ([select id, param1 wtdidlist wtguid = '4a9b5a05-fa43-48d1-af2f-342ea407f4e2']. idlist                                                                 inner join toollists on idlist.id = toollists.nr) on materials.nr = toollists.materialnr) on notetoollists.nr = toollists.nr) on matclasses.nr = materials.matclassnr)                           inner join (tools                                       inner join toollist on tools.nr = toollist.toolnr) on toollists.nr = toollist.toollistnr) on machines.nr = toollists.machinenr)             inner join toolparts on tools.nr = toolparts.toolnr) on parts.id = toolparts.partid order toollists.nr,          toollist.pos,          toollist.t; 

there´s table called siteparts containing column named place - need retrieve value in column value of column partid equal column idin table parts

so tried add code above:

inner join (select place siteparts) on siteparts.partid = parts.id

so attempt:

 select toollists.ident,            toollists.descript tldescript,            toollists.materialnr,            toollists.order,            toollists.who,            toollists.ncp,            toollists.rem tlrem,            toollists.mdate,            toollists.tdate,            toollists.gdate,            toollist.t,            machines.name machinename,            machines.trelation,            toollist.d,            toollist.h,            toollist.pos toollistpos,            toollist.rem toollistrem,            toollist.how toollisthow,            tools.nr,            tools.z1,            tools.drawing,            tools.x1,            tools.sort,            tools.design,            tools.descript,            tools.rem toolrem,            toolparts.pos toolpartpos,            toolparts.nbr,            toolparts.how,            parts.unr,            parts.mid,            parts.descript,            parts.sort,            parts.design,            parts.urem,            parts.dmc,            parts.clength,            parts.cmainarc,            parts.cradius,            parts.uactiv,            matclasses.dmc,            matclasses.description,            matclasses.quality,            notetoollists.notetext,            siteparts.place     parts     inner join ( (machines                   right join ( (matclasses                                 right join (notetoollists                                             right join (materials                                                         right join ([select id, param1 wtdidlist wtguid = '4a9b5a05-fa43-48d1-af2f-342ea407f4e2']. idlist                                                                     inner join toollists on idlist.id = toollists.nr)                                                         inner join                                                           (select place                                                            siteparts)) on materials.nr = toollists.materialnr) on notetoollists.nr = toollists.nr) on matclasses.nr = materials.matclassnr)                   inner join (tools                               inner join toollist on tools.nr = toollist.toolnr) on toollists.nr = toollist.toollistnr) on machines.nr = toollists.machinenr)     inner join toolparts on tools.nr = toolparts.toolnr) on parts.id = toolparts.partid on partid = parts.id     order toollists.nr,              toollist.pos,              toollist.t; 

but server rejecting query, following message:

msg 156, level 15, state 1, line 1 incorrect syntax near keyword 'order'. msg 102, level 15, state 1, line 9 incorrect syntax near ')'. 

i have revisited bunch of times i´m not being able handle long query correctly. can point me i´m doing wrong?

it´s obvious i´m not in sql previous guy, need catch , try make things work current code rather re-write because don´t how made it.

even though query quite complex , use rewriting, answer should quite simple.

add select-part:

siteparts.place 

... did in attempt (with comma between entry , previous/next entries).

then add in new line above order by-line:

inner join siteparts on siteparts.partid = parts.id 

that should it.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -