Re: Variable in select top
Shawn Green <[email protected]>
| Newsgroups | gmane.comp.db.mysql.windows |
|---|---|
| Message-ID | <[email protected]> |
--- Harpreet <[email protected]> wrote: > > I am trying to run sql select using a variable but with no luck > > Select top @max_limit * from table but it doesnto work. Please help > > That's because you are trying to write a MS-specific SQL command. MySQL doesnt have the TOP modifier. It uses a LIMIT clause at the end of the SELECT statement. http://dev.mysql.com/doc/refman/4.1/en/select.html LIMIT clauses only work with constant values. If you do not create the SELECT...LIMIT statement as a fully formed string (in the programming/scripting language that you are using to execute your statements) or use a replaceable parameter in a prepared statement (v5.0+), you will not be able to use a variable value for the LIMIT clause. http://dev.mysql.com/doc/refman/5.0/en/sqlps.html Shawn Green Database Administrator Unimin Corporation - Spruce Pine __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- MySQL Windows Mailing List For list archives: http://lists.mysql.com/win32 To unsubscribe: http://lists.mysql.com/[email protected]