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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:08:26+00:00 2026-05-31T19:08:26+00:00

I have a question. I have here 2 tables table 1 : products product_id

  • 0

I have a question.

I have here 2 tables

table 1 : products

product_id , name , images_sideview

table 2 : product_descriptions

product_id , volgnr

I want to sort them with the numbers from Table 2 and volgnr field.

Is there a way to do this with mysql ?

  • 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-31T19:08:27+00:00Added an answer on May 31, 2026 at 7:08 pm

    There are 2 ways to sort. Ascending order and Descending order. You have not mentioned the order. So I am providing you both answers with 2 variations:

    ASCENDING ORDER:

    SELECT DISTINCT table1.*
    FROM table1
    INNER JOIN table2 ON table1.product_id = table2.product_id
    GROUP BY table1.product_id
    ORDER BY table2.product_id ASC, table2.volgnr ASC;
    

    DESCENDING ORDER:

    SELECT DISTINCT table1.*
    FROM table1
    INNER JOIN table2 ON table1.product_id = table2.product_id
    GROUP BY table1.product_id
    ORDER BY table2.product_id DESC, table2.volgnr DESC;
    

    If you want to tell MySQL to first sort FIRST by volgnr and then by product_id:

    ASCENDING ORDER:

    SELECT DISTINCT table1.*
    FROM table1
    INNER JOIN table2 ON table1.product_id = table2.product_id
    GROUP BY table1.product_id
    ORDER BY table2.volgnr ASC, table2.product_id ASC;
    

    DESCENDING ORDER:

    SELECT DISTINCT table1.*
    FROM table1
    INNER JOIN table2 ON table1.product_id = table2.product_id
    GROUP BY table1.product_id
    ORDER BY table2.volgnr DESC, table2.product_id DESC;
    

    Hope that helps.

    Edit 1:

    I have now edited the query so that it does not give you duplicates in results. Try it out and let me know how that goes.

    Edit 2:
    Added Group By clause. Try this out.

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

Sidebar

Related Questions

Apologies for the vague question. Here it is: I have a table object created
I have a product table called products It has 3 fields (name,model(PK), and class_name).
I have 3 tables: products (id, name, price, etc) orders (id, date, payment_method, etc)
I have a similar question to this one SQL products/productsales I want to do
I have 3 tables Products product_id max_products_can_sell max_products_can_sell_to_individual purchases user_id product_id quantity reservations product_id
Hello StackOverflow community, I have 2 tables products ======= id name prices ====== id
I have a question here regarding iPhone app submission. I have a free application
I have a quick question here. I know that the cakePHP find('first') function returns
I have a silly question here. I define a class with many data members,
C# question here.. I have a UTF-8 string that is being interpreted by a

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.