I have this query:
SELECT certREF,CAST(SUBSTRING_INDEX(certREF,'-',-1) as UNSIGNED) as REF
FROM certificatecatalog
WHERE certREF is not null AND `certREF` REGEXP 'F[\d]+-[\d]+'
ORDER BY REF DESC
Limit 0,1
I have data rows in column certREF like:
F17-1257
F17-3546
F18-8854
F19-9854
I want to be able to pull the highest number after "Fnumber-"
The regualar expression seems to work when i put it in one of those live regex testers.
However i'm getting an empty result set.
If someone could let me know where i'm going wrong :)
Thanks
REGEXP '^F[0-9]+-[0-9]+$'(see demo).