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.

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.

Thank you very much!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.