Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:26:05+00:00 2026-05-28T21:26:05+00:00

I have a mySQl db (name stocks) with 50 tables, each tables with id,

  • 0

I have a mySQl db (name “stocks”) with 50 tables, each tables with

id, symbol, date, time, open, high, low, close, volume as columns (9 columns).

I would like to know what is the last record for each table, ordered for date then time.

Should I have to ORDER BY all data for each table or there is a better way to just know last record?

I am asking help for a query that just return only last record for each table in db.

Thanks

PS For last record I mean most recent as Date then Time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:26:05+00:00Added an answer on May 28, 2026 at 9:26 pm

    There are two options how to do that:

    -- I would use this only if you need more than one records
    SELECT * FROM table ORDER BY date DESC LIMIT 1;
    
    -- Way to go:
    SELECT * FROM table WHERE date = (SELECT MAX(date) FROM table) LIMIT 1;
    

    Don’t forget to add index on date. If it’s possible you add lot’s of records at the same time you will have to add:

    ORDER BY id DESC -- In case that date is highest for records for last records
    ORDER BY time DESC -- Every other case
    

    To the end of query

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose i have a mysql table name table with fields rank date id The
I have a very simple MySQL table Name | Time | Count James |
I have two MySQL tables: attributes (attributeid, name) productsattributes (productid, attributeid, displayvalue) The required
I have a mysql query mysql_query(SELECT name,symbol FROM scode WHERE change='$change' AND product='$product' AND
I have mysql table with collumns like 'operation.date', 'operation.name' and etc. After fetching that
I have MySQL InnoDB table utf-8 encoded. This table has only id and name
i have such mysql db table: id name surname number 1 emil asadi 26
I have a mysql table structure like that: id int primary key name varchar
I have a MySQL table structured somewhat like this: type name value ===================== 1
I have a mysql database with a table structure like below : Table Name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.