![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, Using MySQL, i'm selecting a list of songs in spanish that i would like to sort. Here's a demo of the list of names that is returned by the query: ¡Decirevilla! Alhambra 123 pasitos África Arroz Decir The sorted list should look like this: 123 pasitos África Alhambra Arroz ¡Decirevilla! Decir In other words, some special characters should be ignore (!, ?, ¡, ', ¿, etc...) when sorting and other characters should use the natural equivalent for sorting (Á -> A... É -> E...) After all of the research i've read, i'm not sure if there is a way to achieve this using MySQL. I was thinking of ignoring certain characters (¡, ?, ', !, ¿) and maybe replacing other characters with the natural equivalent (Á -> A, É -> E, etc..), but i'm not sure if it's the right path to go.... Does it make sense? Is this feasable in MySQL? Thanks in advance for all your advice. Marco |
#3
| ||||
| ||||
|
|
Hello, Using MySQL, i'm selecting a list of songs in spanish that i would like to sort. Here's a demo of the list of names that is returned by the query: ¡Decirevilla! Alhambra 123 pasitos África Arroz Decir The sorted list should look like this: 123 pasitos África Alhambra Arroz ¡Decirevilla! Decir In other words, some special characters should be ignore (!, ?, ¡, ', ¿, etc...) when sorting and other characters should use the natural equivalent for sorting (Á -> A... É -> E...) After all of the research i've read, i'm not sure if there is a way to achieve this using MySQL. I was thinking of ignoring certain characters (¡, ?, ', !, ¿) and maybe replacing other characters with the natural equivalent (Á -> A, É -> E, etc..), but i'm not sure if it's the right path to go.... Does it make sense? Is this feasable in MySQL? Thanks in advance for all your advice. Marco |
|
t | +----------------+ 123 pasitos | Alhambra | Arroz | Decir | ¡Decirevilla! | África | +----------------+ |
|
t | +----------------+ 123 pasitos | ¡Decirevilla! | África | Alhambra | Arroz | Decir | +----------------+ |
|
t | +----------------+ 123 pasitos | Alhambra | Arroz | África | ¡Decirevilla! | Decir | +----------------+ |
#4
| |||
| |||
|
|
On 04-03-11 04:50, SM wrote: Hello, Using MySQL, i'm selecting a list of songs in spanish that i would like to sort. Here's a demo of the list of names that is returned by the query: ¡Decirevilla! Alhambra 123 pasitos África Arroz Decir The sorted list should look like this: 123 pasitos África Alhambra Arroz ¡Decirevilla! Decir In other words, some special characters should be ignore (!, ?, ¡, ', ¿, etc...) when sorting and other characters should use the natural equivalent for sorting (Á -> A... É -> E...) After all of the research i've read, i'm not sure if there is a way to achieve this using MySQL. I was thinking of ignoring certain characters (¡, ?, ', !, ¿) and maybe replacing other characters with the natural equivalent (Á -> A, É -> E, etc..), but i'm not sure if it's the right path to go.... Does it make sense? Is this feasable in MySQL? Thanks in advance for all your advice. Marco CREATE TABLE `sp` ( * `t` varchar(20) character set utf8 collate utf8_bin default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * from sp order by t; +----------------+ | t * * * * * * *| +----------------+ | 123 pasitos * *| | Alhambra * * * | | Arroz * * * * *| | Decir * * * * *| | ¡Decirevilla! | | África * * * *| +----------------+ CREATE TABLE `sp` ( * `t` varchar(20) character set utf8 collate utf8_spanish2_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t * * * * * * *| +----------------+ | 123 pasitos * *| | ¡Decirevilla! | | África * * * *| | Alhambra * * * | | Arroz * * * * *| | Decir * * * * *| +----------------+ CREATE TABLE `sp` ( * `t` varchar(20) character set latin1 collate latin1_spanish_ci NOT NULL default '', * PRIMARY KEY *(`t`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t * * * * * * *| +----------------+ | 123 pasitos * *| | Alhambra * * * | | Arroz * * * * *| | África * * * *| | ¡Decirevilla! | | Decir * * * * *| +----------------+ .... -- Luuk |
#5
| |||
| |||
|
|
On Mar 4, 2:03 pm, Luuk<L... (AT) invalid (DOT) lan> wrote: On 04-03-11 04:50, SM wrote: Hello, Using MySQL, i'm selecting a list of songs in spanish that i would like to sort. Here's a demo of the list of names that is returned by the query: ¡Decirevilla! Alhambra 123 pasitos África Arroz Decir The sorted list should look like this: 123 pasitos África Alhambra Arroz ¡Decirevilla! Decir In other words, some special characters should be ignore (!, ?, ¡, ', ¿, etc...) when sorting and other characters should use the natural equivalent for sorting (Á -> A... É -> E...) After all of the research i've read, i'm not sure if there is a way to achieve this using MySQL. I was thinking of ignoring certain characters (¡, ?, ', !, ¿) and maybe replacing other characters with the natural equivalent (Á -> A, É -> E, etc..), but i'm not sure if it's the right path to go.... Does it make sense? Is this feasable in MySQL? Thanks in advance for all your advice. Marco CREATE TABLE `sp` ( `t` varchar(20) character set utf8 collate utf8_bin default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * from sp order by t; +----------------+ | t | +----------------+ | 123 pasitos | | Alhambra | | Arroz | | Decir | | ¡Decirevilla! | | África | +----------------+ CREATE TABLE `sp` ( `t` varchar(20) character set utf8 collate utf8_spanish2_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t | +----------------+ | 123 pasitos | | ¡Decirevilla! | | África | | Alhambra | | Arroz | | Decir | +----------------+ CREATE TABLE `sp` ( `t` varchar(20) character set latin1 collate latin1_spanish_ci NOT NULL default '', PRIMARY KEY (`t`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t | +----------------+ | 123 pasitos | | Alhambra | | Arroz | | África | | ¡Decirevilla! | | Decir | +----------------+ .... -- Luuk that's exactly my point... no collation or charset will work on this case... I mean, why would you want to sort a character like ¡ or ? or ¿... anyways, that's not the point... After a day of researching and asking around, i believe that i'm better off letting MySQL handle the sorting and not the PHP. For that, i need to build an artificial column in my table that does sort properly... a column called, say, sortable_title; then ORDER BY sortable_title... When doing INSERTs and UPDATE's, I will use use a normalize() function in PHP that produces a list with no punctuation, all lower case, accents stripped, etc... I believe at the end, that it's the best solution... Thanks for all of your tips and guiding. |
#6
| |||
| |||
|
|
On Mar 4, 2:03 pm, Luuk <L... (AT) invalid (DOT) lan> wrote: On 04-03-11 04:50, SM wrote: Hello, Using MySQL, i'm selecting a list of songs in spanish that i would like to sort. Here's a demo of the list of names that is returned by the query: ¡Decirevilla! Alhambra 123 pasitos Ãfrica Arroz Decir The sorted list should look like this: 123 pasitos Ãfrica Alhambra Arroz ¡Decirevilla! Decir In other words, some special characters should be ignore (!, ?, ¡, ', ¿, etc...) when sorting and other characters should use the natural equivalent for sorting (à -> A... É -> E...) After all of the research i've read, i'm not sure if there is a way to achieve this using MySQL. I was thinking of ignoring certain characters (¡, ?, ', !, ¿) and maybe replacing other characters with the natural equivalent (à -> A, É -> E, etc..), but i'm not sure if it's the right path to go.... Does it make sense? Is this feasable in MySQL? Thanks in advance for all your advice. Marco CREATE TABLE `sp` ( `t` varchar(20) character set utf8 collate utf8_bin default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * from sp order by t; +----------------+ | t | +----------------+ | 123 pasitos | | Alhambra | | Arroz | | Decir | | ¡Decirevilla! | | Ãfrica | +----------------+ CREATE TABLE `sp` ( `t` varchar(20) character set utf8 collate utf8_spanish2_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t | +----------------+ | 123 pasitos | | ¡Decirevilla! | | Ãfrica | | Alhambra | | Arroz | | Decir | +----------------+ CREATE TABLE `sp` ( `t` varchar(20) character set latin1 collate latin1_spanish_ci NOT NULL default '', PRIMARY KEY (`t`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t | +----------------+ | 123 pasitos | | Alhambra | | Arroz | | Ãfrica | | ¡Decirevilla! | | Decir | +----------------+ .... -- Luuk that's exactly my point... no collation or charset will work on this case... I mean, why would you want to sort a character like ¡ or ? or ¿... anyways, that's not the point... After a day of researching and asking around, i believe that i'm better off letting MySQL handle the sorting and not the PHP. For that, i need to build an artificial column in my table that does sort properly... a column called, say, sortable_title; then ORDER BY sortable_title... When doing INSERTs and UPDATE's, I will use use a normalize() function in PHP that produces a list with no punctuation, all lower case, accents stripped, etc... I believe at the end, that it's the best solution... |
#7
| |||
| |||
|
|
On Mar 4, 2:03 pm, Luuk<L... (AT) invalid (DOT) lan> wrote: On 04-03-11 04:50, SM wrote: Hello, Using MySQL, i'm selecting a list of songs in spanish that i would like to sort. Here's a demo of the list of names that is returned by the query: ¡Decirevilla! Alhambra 123 pasitos África Arroz Decir The sorted list should look like this: 123 pasitos África Alhambra Arroz ¡Decirevilla! Decir In other words, some special characters should be ignore (!, ?, ¡, ', ¿, etc...) when sorting and other characters should use the natural equivalent for sorting (Á -> A... É -> E...) After all of the research i've read, i'm not sure if there is a way to achieve this using MySQL. I was thinking of ignoring certain characters (¡, ?, ', !, ¿) and maybe replacing other characters with the natural equivalent (Á -> A, É -> E, etc..), but i'm not sure if it's the right path to go.... Does it make sense? Is this feasable in MySQL? Thanks in advance for all your advice. Marco CREATE TABLE `sp` ( `t` varchar(20) character set utf8 collate utf8_bin default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * from sp order by t; +----------------+ | t | +----------------+ | 123 pasitos | | Alhambra | | Arroz | | Decir | | ¡Decirevilla! | | África | +----------------+ CREATE TABLE `sp` ( `t` varchar(20) character set utf8 collate utf8_spanish2_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t | +----------------+ | 123 pasitos | | ¡Decirevilla! | | África | | Alhambra | | Arroz | | Decir | +----------------+ CREATE TABLE `sp` ( `t` varchar(20) character set latin1 collate latin1_spanish_ci NOT NULL default '', PRIMARY KEY (`t`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +----------------+ | t | +----------------+ | 123 pasitos | | Alhambra | | Arroz | | África | | ¡Decirevilla! | | Decir | +----------------+ .... -- Luuk that's exactly my point... no collation or charset will work on this case... I mean, why would you want to sort a character like ¡ or ? or ¿... anyways, that's not the point... After a day of researching and asking around, i believe that i'm better off letting MySQL handle the sorting and not the PHP. For that, i need to build an artificial column in my table that does sort properly... a column called, say, sortable_title; then ORDER BY sortable_title... When doing INSERTs and UPDATE's, I will use use a normalize() function in PHP that produces a list with no punctuation, all lower case, accents stripped, etc... I believe at the end, that it's the best solution... Thanks for all of your tips and guiding. |
#8
| |||
| |||
|
|
On 3/4/2011 7:50 PM, SM wrote: ....... |
|
normalize() function in PHP that produces a list with no punctuation, all lower case, accents stripped, etc... I believe at the end, that it's the best solution... Thanks for all of your tips and guiding. If you're insisting on adding another column for sorting, then update it with a trigger. Don't depend on the application to do it. |
#9
| |||
| |||
|
|
On 05-03-2011 15:10, Jerry Stuckle wrote: On 3/4/2011 7:50 PM, SM wrote: ...... When doing INSERTs and UPDATE's, I will use use a normalize() function in PHP that produces a list with no punctuation, all lower case, accents stripped, etc... I believe at the end, that it's the best solution... Thanks for all of your tips and guiding. If you're insisting on adding another column for sorting, then update it with a trigger. Don't depend on the application to do it. But that will only be possible if the function he describes above available is in mysql... |
#10
| |||
| |||
|
|
On 05-03-2011 15:10, Jerry Stuckle wrote: On 3/4/2011 7:50 PM, SM wrote: ...... When doing INSERTs and UPDATE's, I will use use a normalize() function in PHP that produces a list with no punctuation, all lower case, accents stripped, etc... I believe at the end, that it's the best solution... Thanks for all of your tips and guiding. If you're insisting on adding another column for sorting, then update it with a trigger. Don't depend on the application to do it. But that will only be possible if the function he describes above available is in mysql... And is about as silly as saying that you cant rely on a PHP or other |
![]() |
| Thread Tools | |
| Display Modes | |
| |