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 6873093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:00:51+00:00 2026-05-27T04:00:51+00:00

I have a MySQL table with the following fields: id, morning, evening, event, other-fields

  • 0

I have a MySQL table with the following fields:

id, morning, evening, event, other-fields

For about one week, each day some event will occur either in morning or in evening. Thus the events are recorded in the table with the “day-number” stored in “morning” or “evening” field(if the event is to occur in morning, then morning field contains the “day-number” and evening field contains 0. and vise-versa). These entries are not made sequence-wise or day wise but as per the user’s own will.

I need to fetch these records in proper order i.e. Sort the records day-wise in ascending order and records of each day need to be sorted session-wise(i.e. morning first and then evening ones).

Please help with an idea to order the data on these two fields.

Following is some sample data for three days:

id,     mor,       even,     otherstuff....
1         1          0
2         3          0
3         3          0
4         2          0
5         3          0
6         3          0
--------------------------
7         0          1
8         0          2
9         0          3
10        0          3
----------------------

Following is the same above data in the format I need to fetch it:

id,      mor,       even,     otherstuff....
1         1          0
2         0          1
--------------------------
3         2          0
4         0          2
------------------------
5         3          0
6         3          0
7         3          0
8         3          0
9         0          3
10        0          3
  • 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-27T04:00:51+00:00Added an answer on May 27, 2026 at 4:00 am

    If one of them is always zero, the day number will be equal to mor + even so you can sort by that.

    select *
    from your_table
    order by (mor + even), even;
    

    Since even = 0 for “day” records, they will appear before any “even” records on the same day number.

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

Sidebar

Related Questions

I have the following mysql table called pics, with the following fields and sample
Hi I have a mysql table having the following fields A INT, B INT,
I have a MySQL table which contains the following two fields (There are others,
I have a MySQL table with the following fields: Email, Flag1, Flag2 The question:
I have a 'Comments' MySQL table that has the following fields: id text parent_id
I have the following MySQL table fields: description1 , description2 , description3 : Varchar(500)
So I'm using PHP/MySQL and I have a tbl_profile table with the following fields:
I have mysql table with following fields id (which auto increments) title,name,age,institution,iod the fields
I have a MySQL table comment with the following fields: loginid submissionid points I
I have a MySQL table and one of the fields is category, the values

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.