Jump to content

[RESOLVED]MSSQL guy having trouble with a MySQL statement


setaside

Recommended Posts

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.