I Have column exe_production
inside users_acts
table with data like `blah blah blah 10.10.2020 (any date) blah blah.
I need to order this column by date.
My steps:
-
Get date from string by next query:
SELECT REGEXP_REPLACE((SELECT exe_production FROM users_acts LIMIT 1), '[^[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{4}]', '');
-
Convert all results strings to date by
DATE_FORMAT
statement. -
Apply
ORDER BY
statement.
The problem is that I can't apply first query for multiple rows/values, only by LIMIT 1
. How I can solve it?
Best Answer
Your idea was good, but you need
STR_TO_DATE
and you need theREGEXP_REPLACE
in theSELECT
not around a subselectdb<>fiddle here