Variable in select top


I am trying to run sql select using a variable but with no luck

Select top [at] max_limit * from table but it doesnto work. Please help


--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=3Dgcdmw-win32 [at] m.gmane.org
Harpreet [ Di, 11 April 2006 06:40 ] [ ID #1269418 ]

Re: Variable in select top

--- Harpreet <harpreet [at] crispincorp.com> wrote:

>
> I am trying to run sql select using a variable but with no luck
>
> Select top [at] 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/win32?unsub=gcdmw-win32 [at] m.gmane.org
Shawn Green [ Di, 11 April 2006 15:32 ] [ ID #1269419 ]
Datenbanken » gmane.comp.db.mysql.windows » Variable in select top

Vorheriges Thema: table type and server load
Nächstes Thema: Mysql over HTTP