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

Projects

None yet

2 participants

@sringel
sringel commented Aug 8, 2011

Example:
var videos = new Videos(); var headlines = videos.All(where: "headline = @0", orderBy: "createDESC", 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: "createDESC", columns: "videoid", args: 1).Take(5);

@robconery
Collaborator

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.

@robconery robconery closed this Aug 9, 2011
@sringel
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