Small MSSQL problem

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2007
Posts: 23
Reputation: Wiizl is an unknown quantity at this point 
Solved Threads: 0
Wiizl Wiizl is offline Offline
Newbie Poster

Small MSSQL problem

 
0
  #1
Oct 16th, 2009
I'm using this piece of code to get the number of search results. However it says- Incorrect syntax near ')' (the very last ')' )
  1. SELECT COUNT(*) FROM
  2. (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.
Last edited by Wiizl; Oct 16th, 2009 at 8:14 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,248
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 578
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
1
  #2
Oct 16th, 2009
You need to name the table alias in your sub select.

This will fail:
  1. SELECT Count(*)
  2. 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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 23
Reputation: Wiizl is an unknown quantity at this point 
Solved Threads: 0
Wiizl Wiizl is offline Offline
Newbie Poster
 
0
  #3
Oct 16th, 2009
Thank you very much!!!
Reply With Quote Quick reply to this message  
Reply

Tags
sql

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC