Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specifying a limit parameter creates incorrect MySQL query, MySQL doesn't support the TOP keyword #76

Closed
sringel opened this issue Aug 8, 2011 · 2 comments

Comments

@sringel
Copy link

sringel commented Aug 8, 2011

Example:
var videos = new Videos(); var headlines = videos.All(where: "headline = @0", orderBy: "create DESC", limit: 5, columns: "videoid", args: 1);

Create a SQL query like "SELECT TOP 5 videoid FROM videos WHERE headline = 1 ORDER BY create DESC;", which MySQL throws the following error:

/* SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '5 videoid FROM videos WHERE headline = 1 ORDER BY create DESC' at line 1 */

Workaround using Linq:

var videos = new Videos(); var headlines = videos.All(where: "headline = @0", orderBy: "create DESC", columns: "videoid", args: 1).Take(5);

@robconery
Copy link
Contributor

Right - this isn't an issue, it's a given. Remember, this is a code file - not a DLL or toolset. If you're using MySQL, you'll need LIMIT instead of TOP.

@sringel
Copy link
Author

sringel commented Aug 9, 2011

No problem, my mistake, I misread the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants