MySQL treats ÅÄÖ as AAO?

后端 未结 5 738
粉色の甜心
粉色の甜心 2020-11-30 02:21

These two querys gives me the exact same result:

select * from topics where name=\'Harligt\';
select * from topics where name=\'Härligt\';

5条回答
  •  我在风中等你
    2020-11-30 03:16

    Since you are in Sweden I'd recommend using the Swedish collation. Here's an example showing the difference it makes:

    CREATE TABLE topics (name varchar(100) not null) CHARACTER SET utf8;
    
    INSERT topics (name) VALUES ('Härligt');
    
    select * from topics where name='Harligt';
    'Härligt'
    
    select * from topics where name='Härligt';
    'Härligt'    
    
    ALTER TABLE topics MODIFY name VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_swedish_ci;
    
    select * from topics where name='Harligt';
    
    
    select * from topics where name='Härligt';
    'Härligt'
    

    Note that in this example I only changed the one column to Swedish collation, but you should probably do it for your entire database, all tables, all varchar columns.

提交回复
热议问题