There is a query: SELECT (SELECT TOP 1 u.id FROM [dbo].[TABLE] tab (nolock) LEFT JOIN BD.dbo.users u ON u.id=tab.menID WHERE tab.ID = t.mID) c_id FROM dbo.[Tables] t (nolock) WHERE c_id=1
The error is Invalid column name 'c_id'.
How can I refer to the c_id
column to set a condition? Thank.
select * from (ваш запрос) where c_id=1
. But it will turn out very badly. because first all records from Tables will be selected, then a subquery will be executed for each of them and finally a condition will be applied which will filter the records. Worth looking for a radically different approach to the problem - Mike