problem with select within select
-
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) = 1Its 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
-
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) = 1Its 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
Well, I am not sure what are you trying to say with that T-SQL code but I think your query looks like this:
select * , ( select vRefTable from mainmenu where iMenuId=58 ) from TableField where vFieldsName iMenuId=58 and bIsPrimary=1 and iTableFieldId=11
For more help post more descriptive question.
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.
-
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) = 1Its 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
Hi I have tried to analyse my requirement below.
mainmenu--TableName
iMenuId vRefTable----ColoumnNames
58 news ---------RecordsTableField
iMenuId bIsPrimary iTableFieldId vFieldsName
58 1 11 iNewsIdnews
iNewsId vTitle vUR
1 news1 http://www.gmail.comI am storing tablenames in MainMenu in vRefTable coloumn and coloumn names in vFieldsName of TableFields table. I want to extract tablename from MainMenu whose iMenuId=58 and coloumn name from TableField table whose iMenuId=58 and bIsPrimary=1 and iTableFieldId=11 i.e iNewsId. After this I will be having both table name and coloumn name, using this I want to extract data based on the table name & coloumn name which I am having. Thanks again Ansari
-
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) = 1Its 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
Well, I'm not sure what you are trying to acheive, and in my opinion its a rubbish way of doing it, but your problem is (I think) that you need to alias you sub-selects.
select *
from ( select vRefTable from mainmenu where iMenuId=58 ) as a
where (select vFieldsName from TableField where iMenuId=58and bIsPrimary=1 and iTableFieldId=11) as b = 1But I still think you should re-write it
Bob Ashfield Consultants Ltd