> Ok, I thought that I will be misunderstood... 
> 
> I'll try to explain this in example below:
> 
> I have table
> 
> CREATE TABLE `product_descriptions` (
>   `id_product_description` mediumint(8) unsigned NOT NULL auto_increment,
>   `id_product` mediumint(8) unsigned NOT NULL default '0',
>   `lang` varchar(2) default NULL,
>   `text_data` text,
>   PRIMARY KEY  (`id_product_description`),
> ) ENGINE=MyISAM DEFAULT CHARSET=utf8
> 
> 
> in column `text_data` i have all texts in all languages (pl, en, ru etc.) So the 
> problem
> is that this column is meant to store every collation for this language but in UTF-8.
> Now, when I get records from this table I should give database some info that I will 
> use
> i.e. 'utf_8_polish_ci' collation on whole page - I don't need to change it on whole 
> page
> (I use PHP by the way)
> 
> This solution I use is very handy as when I need to add some language to my pages 
> then I
> only add some info in application about what language this would be and... this 
> should
> work. I can't change database structure on every language upgrade. Besides I would 
> have
> for example 20 columns with different collations like:
> 
> text_data_pl
> text_data_ru
> text_data_ro
> text_data_en
> text_data_...
> 
> and this table is not the only one which stores information in different 
> languages... So
> please consider this and please if you know tell me what collation_connection is for.
> 
> -- 
> "Use the force - read the source"
> Piotr Duszynski                          mailto:[EMAIL PROTECTED]


Ok, now I think I understand better...

from mysql manual:

"collation_connection is important for comparisons of literal strings.
For comparisons of strings with column values, it does not matter
because columns have a higher collation precedence."

http://dev.mysql.com/doc/mysql/en/Charset-connection.html

If I understand this correctly this means that the _only_ time
collation_connection is used is for an SQL statement like this:

SELECT col1 FROM table1 WHERE "stringliteral1" = "stringliteral2";

This isn't a very useful SQL query but it is legal and the only way to
know how to compare the two string literals is to have a variable called
collation_connection.  When you are comparing, for example, a string
literal to a column the collation of the column has a higher precedence
than the collation_connection variable which is used for the string.  

Therefore the _only_ way to compare a string against a column without
using the column's default collation is to explicitly specify which
collation to use in the comparison with a COLLATE clause like this
"COLLATE utf8_polish_ci".

It might be a little more work but you'll probably have to dynamically
add a COLLATE clause to all your queries based on the language you want.

best regards,
Jeremy


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to