INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Limiting a Query result to the last 50 records

Limiting a Query result to the last 50 records

(OP)
I have a query that is getting me ALL the records from two tables. For one application I have I only need the last 30 records. I tried Limit 30 but that only got me the first 30. The table is ever growing so I will never know the number of records in the tables until I run the query. Here's my query:

$sql = "SELECT a.dealer_name, a.pi_name, b.pub_ip, b.date, b.time, b.latency, b.jitter, b.loss, b.mos, b.sip_status_before FROM pi_config a, pi_data b WHERE a.pi_id = b.pi_id ORDER BY b.date";


How can I do this??

Thanks alot for looking

RE: Limiting a Query result to the last 50 records

Order descending (ORDER BY b.date DESC) and then take LIMIT 30.

Bye, Olaf.

RE: Limiting a Query result to the last 50 records

For more see -> the MySQL documentation

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close