Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / General DB Topics / General DB Topics / August 2003

Tip: Looking for answers? Try searching our database.

the equivalent of "top" from mssql in mysql

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim - 19 Aug 2003 15:28 GMT
Im trying to pull the last 5 entered rows in a mysql table...

in MSSQL i can use the following query "Select top 5 * from employees;"

Whats the query that I can use for MYSQL?

-Jim
Ed prochak - 19 Aug 2003 18:22 GMT
> Im trying to pull the last 5 entered rows in a mysql table...
>
[quoted text clipped - 3 lines]
>
> -Jim

These Last/First X rows always bother me. Why? They show that many
folks still treat relational databases as if they were file systems.

One of the fundamental concepts in relational databases is:
there is NO ORDER to the set of data contained in a table.

IOW, there is no such concept as the last 5 rows of a table!

Check the SQL standard. There is not TOP keyword. No LAST or FIRST
either. No ROWNUM

-----

With that out of the way, lets get to your question. In order to
answer, we need to know what you mean by "the last 5 entered rows". Is
that alphabetical order? (first name or last name?) Is it by when the
employee started? (hire date? or application received date?) Or maybe
by age (birthdate)? By height?

Once you define what you need/mean you'll see how to write the query
easily.

I honestly hope this helps.
 Ed
Dave Benjamin - 19 Aug 2003 20:11 GMT
> Im trying to pull the last 5 entered rows in a mysql table...
>
> in MSSQL i can use the following query "Select top 5 * from employees;"
>
> Whats the query that I can use for MYSQL?

SELECT * FROM EMPLOYEES LIMIT 5
(you probably want an ORDER BY in there...)

Dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.