MySQL SELECT DISTINCT should be case sensitive?

前端 未结 3 550
旧巷少年郎
旧巷少年郎 2021-02-05 14:49

How do I make MySQL\'s SELECT DISTINCT case sensitive?

create temporary table X (name varchar(50) NULL);
insert into X values (\'this\'), (\'This\');
         


        
3条回答
  •  天命终不由人
    2021-02-05 15:16

    I would rather update the column definition to be case sensitive collision.

    Like this:

    create table X (name VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_bin NULL);
    insert into X values ('this'), ('This'); 
    

    SQLFiddle: http://sqlfiddle.com/#!2/add276/2/0

提交回复
热议问题