SQLCookbook 学习笔记 6 字符串

来源:互联网 发布:php.ini设置 编辑:程序博客网 时间:2024/06/02 19:43

引号必须成对出现,

两个引号之间没有任何值得时候,表示空串,并不是null,在MySQL中


在返回结果的时候,使用replace函数

select replace(user_name,'2','two') as new from user_info where user_id = 3214 ;


不包含数字字母以外的 其他字符

where data regexp '[^0-9a-zA-Z] = 0'


replace 函数

replace(user_name,'2','two')

第一个参数是 字段名,第二个是被替换的字符串,第三个是替换的新内容,这个例子的意思是 将user_name中的2替换成two。


substr()函数

select substr(name,3,30) from  emp where id = 1;

表示 取name字段 ,从三个字符开始取, 取30个字符。







0 0
原创粉丝点击