mysql 查詢表中列的資料不區分大小寫的解決

2022-05-26 17:00:14 字數 501 閱讀 6281

select * from some_table where str=『abc';

select * from some_table where str='abc';

得到的結果是一樣的,如果我們需要進行區分的話可以按照如下方法來做:

第一種方法:

要讓mysql查詢區分大小寫,可以:

select * from some_table where binary str='abc'

select * from some_table where binary str='abc'

第二方法:

在建表時時候加以標識

create table some_table(

str char(20) binary  

)原理:

對於char、varchar和text型別,binary屬性可以為列分配該列字符集的 校對規則。binary屬性是指定列字符集的二元 校對規則的簡寫。排序和比較基於數值字元值。因此也就自然區分了大小寫。

mysql互換表中兩列資料

mysql互換表中兩列資料 update product set original price price,price original price 上面sql語句顯然不可取 因為先執行original price price original price的值已經更新為price,然後執行price...

mysql互換表中兩列資料

在開發過程中,有時由於業務等需要把乙個表中的兩列資料進行交換。解決方案 使用update命令,這完全得益於mysql sql命令功能的強大支援。中原來資料類似如下 select from product id name original price price 1 雪糕 5.00 3.50 2 鮮花...

Mysql 資料庫 表中列的操作

mysql資料庫中表的列操作 mysql中關於表中列的操作集語句 1 1 增加一列 2alter table cfg fee rate add column transfer area varchar 12 default null comment 目標程式碼區號 34 2 增加一列,在dnis a...