| ★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum4/HTML/000715.html | Nouvelle recherche | Portail wanayoo |
|
|
DevShed Discussion Forums
![]() MySQL
![]() select top row
|
| next newest topic | next oldest topic |
| Author | Topic: select top row |
|
vic Junior Member |
How do I write below sql statement in MySQL: "SELECT TOP 5 * FROM some_table"? This sql statement work in SQL Server. |
|
rod k Member |
top 5 what? select * from some_table order by some_field [asc|desc] limit 5 |
|
vic Junior Member |
Hi, Thanks for the help. By the way, I hardly find all these SQL statement supported by MySQL. Where can I find all these information? Is it only in MySQL manual? Thanks. vic |
|
jcbell Member |
As follows: SELECT * FROM YourTableName LIMIT 5; The LIMIT # function works with the statement just like it does for the UPDATE statement. See: http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#SELECT 7.14 SELECT syntax SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] ------------------ |
|
jcbell Member |
Correcttion: you have to give a search criteria so that you get an ordering: SELECT * FROM YourTableName ORDER BY yourColumnName ASC LIMIT 5; The LIMIT # function works with the statement just like it does for the UPDATE See: 7.14 SELECT syntax SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT]
------------------ |
All times are MST (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1997-2000 ngenuity. All rights reserved.
Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.