Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - Query to order by second column if first column value is same

SELECT * 
FROM `user_job_application` 
ORDER BY `user_job_application`.`user_id` DESC

It gives the table result like image preview. but when user_idis same then, I want to fetch result order by user_job_application_date desc

enter image description here

like image 932
Shubham Mishra Avatar asked Dec 21 '25 10:12

Shubham Mishra


1 Answers

We can ORDER results using multiple columns.

Try this:

SELECT * 
FROM `user_job_application` 
ORDER BY `user_job_application`.`user_id` DESC, user_job_application_date desc
like image 181
DineshDB Avatar answered Dec 24 '25 00:12

DineshDB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!