0

I'm using this piece of code to get the number of search results. However it says- Incorrect syntax near ')' (the very last ')' )

SELECT COUNT(*) FROM
(SELECT  ID, ProductDescription FROM Products WHERE ProductDescription LIKE '%tech%')

The inner select works fine and gives correct results, so I don't understand what's the problem... I won't be surprised if it's something stupid, but I've tried lots of things but with no success..
So I hope you guys can give some hints.

Edited by Wiizl: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Wiizl
1

You need to name the table alias in your sub select.

This will fail:

Select Count(*)
From (Select * From sysobjects)

This will work:

Select Count(*)
From (Select * From sysobjects) as tbl

Just stick an "as tblName" clause regardless of whether you use it.

In the future please post Microsoft SQL Questions to the MSSQL Forum.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.