Print Page | Close Window

SQL Problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2107
Printed Date: 29 March 2026 at 8:32am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: SQL Problem
Posted By: Pegaso
Subject: SQL Problem
Date Posted: 25 April 2003 at 1:21am

The following didn't work. Why??

strSQL = "SELECT tblNewsRating.News_ID, Avg(tblNewsRating.Rating) AS MediadiRating "
strSQL = strSQL & "FROM tblNewsRating "
strSQL = strSQL & "GROUP BY tblNewsRating.News_ID "
strSQL = strSQL & "WHERE tblNewsRating.News_ID = " & rsnews("News_ID") &";"

That's the error message:

Tipo di errore:
Microsoft JET Database Engine (0x80040E14)
Errore di sintassi (operatore mancante) nell'espressione della query 'tblNewsRating.News_ID WHERE tblNewsRating.News_ID = 117'.
/Ticinorally/testing2.asp, line 52

thanks to all for the help

 



-------------



Replies:
Posted By: Pegaso
Date Posted: 25 April 2003 at 1:28am

Sorry I have found now the solution. And for all that have the same problem, here you have the solution:

strSQL = "SELECT tblNewsRating.News_ID, Avg(tblNewsRating.Rating) AS MediadiRating "
strSQL = strSQL & "FROM tblNewsRating "
strSQL = strSQL & "GROUP BY tblNewsRating.News_ID "
strSQL = strSQL & "HAVING tblNewsRating.News_ID = " & rsnews("News_ID") &";"

If you work with a Group you must use Having and not Where.



-------------


Posted By: MorningZ
Date Posted: 25 April 2003 at 11:17am

actually thats not true, you can have

SELECT.. FROM .. WHERE... GROUP

"having" isn't absolutely required



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Pegaso
Date Posted: 02 May 2003 at 8:28am
OK but with the WHERE command the SQL didn't work and with HAVING it works. Why?

-------------


Posted By: MorningZ
Date Posted: 02 May 2003 at 8:33am

notice i didnt say: replace "HAVING" with "WHERE"

there's more than one way to skin a cat

 



-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net