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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:44:48+00:00 2026-06-11T17:44:48+00:00

When using the following query: SELECT id, rater_id, product_id, is_valid FROM `ratings` WHERE (`ratings`.element_id

  • 0

When using the following query:

SELECT id, rater_id, product_id, is_valid  
FROM `ratings` 
WHERE (`ratings`.element_id = 3151) 
ORDER BY id DESC, product_id DESC, is_valid ASC;

i would expect that the result set will first be sorted by id first, then by product_id and then by is_valid.
what actually happens is that the result set is indeed ordered, but the is_valid column in the results appears to be sorted by DESC, not by ASC. tried using both ASC and DESC but the result set stays the same.

+------------------+--------------+------+-----+---------+----------------+
| Field            | Type         | Null | Key | Default | Extra          |
+------------------+--------------+------+-----+---------+----------------+
| id               | int(11)      | NO   | PRI | NULL    | auto_increment |
| user_id          | int(11)      | NO   | MUL | NULL    |                |
| product_id       | int(11)      | YES  | MUL | NULL    |                |
| value            | tinyint(4)   | YES  | MUL | NULL    |                |
| rater_id         | int(11)      | YES  |     | NULL    |                |
| comment          | varchar(350) | YES  |     | NULL    |                |
| created_at       | datetime     | YES  |     | NULL    |                |
| updated_at       | datetime     | YES  |     | NULL    |                |
| element_id       | int(11)      | YES  | MUL | NULL    |                |
| is_valid         | tinyint(1)   | YES  | MUL | 0       |                |
+------------------+--------------+------+-----+---------+----------------+
  • 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-11T17:44:49+00:00Added an answer on June 11, 2026 at 5:44 pm

    The id field is an [unique auto incremental] primary key. This means that regardless of the values product_id and is_valid has, the order of id will render the other two ordering rules useless.

    What I think is that you probably don’t understand that the ORDER BY clause works as a nested ordering and not as an independent ordering of the values of the columns.

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

Sidebar

Related Questions

i've been using the following query: select LEN(columnname) as columnmame from dbo.amu_datastaging This works,
I'm using the following query to select users from my 'users' table with the
I am using the following query to select wait times from the table wait_times
I'm using Oracle 10.2 and have the following query: select h.company, count(*) from history
I am using the following query in my database, SELECT b.sales_id,b.category_id,b.sale_starts,b.sale_ends FROM tbl_sales b
I am trying to code the following query using Zend_Db api's: select * from
Using phpMyAdmin and running the following query I get 19 registers: SELECT * FROM
Using the following query to select data from a table in 15 minute intervals
I am using following SQL Query: SELECT `comment`.`id` AS `comment_id` , count( `comment_likes`.`comment_id` )
I am using following query which works fine for me except one problem SELECT

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.