Jump to content

Does this query from my book make any sense?


eindoofus

Recommended Posts

I took the following query out of the book "Peachprint Press PHP 6 and MySQL 5 for Dynamic Web Sites 2007":

 

SELECT first_name, last_name FROM users ORDER BY last_name ASC, first_name ASC;

 

I don't  understand the point of having "first_name ASC" at the end. As far as I know SQL organizes the table by rows and maintains the relationship within each row.

 

Doesn't SQL just ignore any statement that would follow "last_name ASC"? If it didn't then the relationships within a table would get scrambled, wouldn't they? Would there ever be a reason to include more than one statement after an "ORDER BY"?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.