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

  • Home
  • SEARCH
  • 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 6844177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:20:38+00:00 2026-05-27T00:20:38+00:00

I have 2 tables in MYSQL that will be joined by a foreign key.

  • 0

I have 2 tables in MYSQL that will be joined by a foreign key. Each table has its own date field. What I would like to do is combine these two date fields together and then order by the combined information. I understand that you can order by multiple fields but I don’t think that combines them.

Example

Join by tickets.ticket_id = ticket_history.ticket_id

Table 1

ticket_date

Table 2

ticket_history_date

Goal combine the two date fields and then order the rows by the combined dates

  • 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-27T00:20:39+00:00Added an answer on May 27, 2026 at 12:20 am

    Let’s assume that you want the latest of the two dates, you can do something like this

    SELECT
        [some info],
        GREATEST( ticket_date, ticket_history_date ) as latest_date
    FROM
        [tables and join]
    ORDER BY
        latest_date
    

    If you wanted the oldest date you could use LEAST rather than GREATEST. If one of the dates might be NULL then you might want to look into COALESCE

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

Sidebar

Related Questions

I have one mysql table 'alfa' that will contain the primary key of another
I have a mysql database which has 3 tables that have to be joined
I have a MySQL table that will only have one row. What should my
I have a MySQL database, and a particular table in that database will need
I have a table in MySQL that has 3 fields and I want to
I have a table in MySQL That looks like the following: date |storenum |views
I have mysql table that has a column that stores xml as a string.
I have several tables that get JOINed together to form a table with columns
I have a MySQL database that has a few very simple tables. I would
In MySQL I know its possible to select from two tables that have been

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.