Sorting alphabetically regardless of quotes

Well you could just remove all double quotes and then sort, e.g.

SELECT *
FROM yourTable
ORDER BY REPLACE(name, '"', '');

If you are using MySQL 8+, and want a more surgical way of doing the replacement, you could use REGEXP_REPLACE and strip double quotes only from pairs:

SELECT *
FROM yourTable
ORDER BY REGEXP_REPLACE(name, '"(.*?)"', '$1');

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top