problem with select within select

  • 12 years ago

     Hi

    I want to execute below query in ms-sql server 2000 but its giving errors.
    Can anybody help please.

    select * from ( select vRefTable from mainmenu where iMenuId=58 )
    where (select vFieldsName from TableField where iMenuId=58
    and bIsPrimary=1 and iTableFieldId=11) = 1


    Its showing below errors. your help is greatly appreciated.
    Server: Msg 156, Level 15, State 1, Line 2
    Incorrect syntax near the keyword 'where'.
    Server: Msg 170, Level 15, State 1, Line 3
    Line 3: Incorrect syntax near '='.


    Thanks
    Ansari

  • 12 years ago

    Hi Ansari

      I have identified the problem in your querey. Actually its basic problem.

    In the WHERE clause your not mentioned any field to validate

    As per you query you can only use in the WHERE clause vRefTable [Because you are selecting vRefTable filed only in the subquerey]

    WHERE vRefTable= or IN or NOT IN or etc...

    I hope you can understand where you have made problem in your querey.

     Good Luck

    Regards

    Hari K...... 

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra