MySQL Query Help

I have a table with columns blade_id, class_id, dateReleased_yr . I am trying to run a query which will give me results order by dateReleased_yr desc . This works fine but next step is to group all the blade_id with the same class_id. I tried different combination of order by but didnt work.

//if I just to the dateReleased_yr sort I getblade_id class_id dateReleased_yr1 2 20112 3 20103 2 20104 4 2009//What I want to get is group all the blade_id with same class_id togather with the desc yearblade_id class_id dateReleased_yr1 2 20113 2 20102 3 20104 4 2009

If I do the above query it keeps the order of the class_id and then sort with dateReleased_yr. What I need is to show the blade_id of the same class_id togather. So if a blade_id 4 with class_id 5 is at the top then all the blade_ids with the same class_id will group togather at the top even though these blade_ids have lower dateReleased_yr than other ones.

With the data you showed above, my query produces the exact results you asked for. In phpmyadmin, I created a test table, entered the data, and ran the query. I don't understand what else you want. Post a more complete example of what you want.

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

I agree with Dave on this, the query he has posted is correct if I'm reading your request correctly. If you are after the mechanism that displays the blade_id this can be output after the above query has been executed.

In PHP that script will show the Blade ID, the Class ID and the Date Released in the order of Class ID first and then Date Released. If you're using another language then the syntax naturally would be different.

Attached is the row table data. What I am trying to get from this is, sort the data desc by dateReleased_yr and doing that say I get blade_id 286 on the top. blade_id 286 has a class_id 45 and there could be many blade_ids with the same class_id. I want all the blade_ids with this class_id to show on the top regardless of dateReleased_yr. So say a blade_id 300 has a dateRelealesed_yr of 2007 but it belongs to the same class_id as blade_id 286, I want to show those blades on the top.

From the above query, I get the data sorted by date fine. What I want is, group all the blades from the same class_ids (the class_id which we get when sorting by date) . So running above query, I get blade_id 799 at number 3 which has class_id 185. There are some data with the same class_id with lower dates. I need all those blades to show up after the blade_id 799 so that I get the grouping of class_ids as well. This way I have a blade_id with latest date and all the blade from the same class togather.

Ok, you have a limited number of choices. In the ORDER BY section, you put the fields in the order that you want them sorted. Put the most important first, second most important second, and third most important third.

Featured Post

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .

The viewer will learn the basics of jQuery including how to code hide show and toggles.
Reference your jQuery libraries:
(CODE)
Include your new external js/jQuery file:
(CODE)
Write your first lines of code to setup your site for jQuery…

In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB.
To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…