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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:25:14+00:00 2026-06-07T00:25:14+00:00

I had a question in MySQL, did it correctly. But the book code differs

  • 0

I had a question in MySQL, did it correctly. But the book code differs a little.

Book:

use tennis;
select playerno, datediff(coalesce(end_date, current_date), 
begin_date) as Difference, position
from committee_members
where datediff(coalesce(end_date, current_date), begin_date) > 500
order by 1;

What is this order by 1 ?

My code also works and is almost the same except:

select playerno, datediff(coalesce(end_date, current_date) AS Data,
order by Data;
  • 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-06-07T00:25:15+00:00Added an answer on June 7, 2026 at 12:25 am

    order by 1 means "order by the first field I selected" — i.e., in this case, the same as order by playerno, because playerno was the first field in the list.

    In case you want the official wording, here’s what the SQL-92 standard1 says:

    10)If ORDER BY is specified, then each <sort specification> in the
            <order by clause> shall identify a column of T.
    
            Case:
    
            a) If a <sort specification> contains a <column name>, then T
              shall contain exactly one column with that <column name> and
              the <sort specification> identifies that column.
    
            b) If a <sort specification> contains an <unsigned integer>,
              then the <unsigned integer> shall be greater than 0 and not
              greater than the degree of T. The <sort specification> iden-
              tifies the column of T with the ordinal position specified by
              the <unsigned integer>.
    

    In this case, b is the one that seems to apply.

    More recent versions of the SQL standard have removed this capability though, so new code should generally avoid it. SQL-based database servers have been deprecating it for a while now, but most continue to support it for the sake of backward compatibility. At the same time, the fact that they’ve deprecated it indicates they no longer consider it a feature they really need to support, so it could be removed at any time with no further warning (e.g., if they find a bug in that part of their code, they might decide the best way to fix the bug is to just disable that feature).



    1. This quote is from a freely-available draft rather than the approved standard. While I’m sure there are at least a few changes between this draft and the final text of the standard (not to mention between one version of the standard and another) it seems unlikely that something this fundamental would change between the draft and the final standard.

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

Sidebar

Related Questions

I had a question here Mysql select speed I figure that select of mysql
I had a question regarding this matter some days ago, but I'm still wondering
I had a question on a test - I got it wrong, but I
I had a question about where a MySql database has to sit for a
I had a question earlier involving php and mysql on this same project, This
Had a quick question about joins in mysql and indexing. If I had 2
I've worked with mysql for some time but have never had to do anything
Borderline ServerFault question, but figured I'd try here first since I've had luck with
I moved a mysql DB to Postgres, but some of the tables had a
I have had a long problem with this code. I have posted this question

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.