RE: [PHP-DB] MySQL: Alphabetizing title results in library format

From: Date: Thu, 01 Nov 2001 09:25:26 +0000
Subject: RE: [PHP-DB] MySQL: Alphabetizing title results in library format
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-13904@lists.php.net to get a copy of this message
Hi Ian, Try this: mysql> select *,(case when title like '%The%' then substring (title, 5, 255) when title like '%A%' then substring (title, 3, 255) when title like '%An%' then substring (title, 4, 255) else title end) as sort_col from titles order by sort_col; Hope it helps, Cami -----Original Message----- From: Ian Evans [mailto:ianevans@friedspamdigitalhit.com] Sent: Thursday, November 01, 2001 9:20 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] MySQL: Alphabetizing title results in library format Petr Tuma wrote: > What error message it produce? Ok, table titles is composed of: +----------+-------------+----------------+ | titlesid | releaseyear | title | +----------+-------------+----------------+ mysql> select *,(case when title like 'The %' then substring (title, 5, 255) when title like 'A %' then substring (title, 3, 255) when title like 'An %' then substring (title, 4, 255) else title end) as sort_col from titles order by sort_col; ERROR 1064: You have an error in your SQL syntax near 'when title like 'The %' then substring (title, 5, 255) when title like 'A %' the' at line 1 -- Ian Evans Digital Hit Entertainment - News and Information http://www.digitalhit.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#13904) next »