Cendol404 :
i have database table like this ( idnumber, id_transaction is varchar)
----------------------------------------------
| idnumber | date | id_transaction |
----------------------------------------------
| 12312312 | 2020-03-14 | s1 |
| 12312312 | 2020-03-14 | s9 |
| 12312312 | 2020-03-15 | s13 |
| 12312312 | 2020-03-15 | s14 |
----------------------------------------------
i have this query from my script
select * from transaksi where idnumber='12312312' order by date and REPLACE(id_transaction, "s", "") DESC LIMIT 1
when i run it, i get "s9" result whereas i want to get "s14" result, how do i fix it?
forpas :
This is the correct syntax for the ORDER BY clause:
select * from transaksi
where idnumber='12312312'
order by date desc, REPLACE(id_transaction, 's', '') + 0 desc limit 1
See the demo.
Results:
| idnumber | date | id_transaction |
| -------- | -----------| -------------- |
| 12312312 | 2020-03-15 | s14 |
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=297545&siteId=1