Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE t(number VARCHAR(100) NOT NULL); INSERT INTO t VALUES ('Ол-12/2003'), ('Ол-7/2003'), ('Ол-12/2012'); SELECT * FROM t; SELECT t.*, SUBSTRING_INDEX(SUBSTRING_INDEX(number, '/', 1), '-', -1) FROM t ORDER BY CAST(SUBSTRING_INDEX(number, '/', -1) AS UNSIGNED INTEGER) DESC, CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(number, '/', 1), '-', -1) AS UNSIGNED INTEGER) ASC

Stuck with a problem? Got Error? Ask AI support!

Copy Clear