Jump to content


Photo

[RESOLVED]MSSQL guy having trouble with a MySQL statement


  • Please log in to reply
1 reply to this topic

#1 setaside

setaside
  • New Members
  • Pip
  • Newbie
  • 3 posts
  • LocationKansas City, MO USA

Posted 30 January 2003 - 08:30 PM

Hey guys I\'m new the boards but I hope to travel back here often. I\'ve recently picked up PHP/MySQL for a couple of projects that I\'m working on. One problem that I seem to be having is that I want to return a top 10 list of sorts into a list box. The statement that I\'ve written works great in a MSSQL database that I use for testing, but when I try to execute the statement on my webserver I get an incorrect syntax error. Any ideas on where my syntax has gone wrong? Here is my MSSQL statement.

SELECT TOP 3 COUNT(*) as Total, Title FROM ggListAvailable GROUP BY Title ORDER BY Total DESC

I\'m wondering if it\'s the TOP keyword or perhaps the Alias. Are these keywords supported in MySQL? Thanks in advance for any help guys.[/code]

#2 setaside

setaside
  • New Members
  • Pip
  • Newbie
  • 3 posts
  • LocationKansas City, MO USA

Posted 30 January 2003 - 10:57 PM

I ended up finding the answer at another board. For anybody else who didn\'t know... TOP is not a supported keyword in MySQL. Here is the statement that I ended up using:

SELECT count(*) as Total, Title

FROM ggListAvailable

GROUP BY Title

ORDER BY Total DESC LIMIT 10






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users