Reputation: 690
I want to sort by two columns.Both are strings on is popularity another is createDT in MYSQL. popularity will have number and createDT has 25-05-2016 format.
Am trying the below query. But which ever i keep first i mean i i keep order by popularity ASC, createDT DESC. It is taking first column. I tried keeping STR_TO_DATE also. not working. i want it should check order by both.
SELECT
id,
productId,
productJson
FROM
product
WHERE
subcategory = ?
ORDER BY
STR_TO_DATE(createDt, '%d-%m-%Y') DESC,
popularity ASC
Upvotes: 1
Views: 542
Reputation: 690
SELECT
id,
productId,
productJson,
popularity,
createDt
FROM
product
WHERE
subcategory = ?
ORDER BY
STR_TO_DATE(createDt, '%d-%m-%Y') DESC,
popularity ASC;
It's worked for me.
Upvotes: 1