MySQL 笔记(五)replace ,mid函数用法

    1.replace(st1,str2,str3)

    在字串str1中,str2出现,就会用str3代替。

    world(id,name,capital)

    2.mid(column_name,start,stop)

    column:要提取字符的字段,不能省略; start:规定开始位置,不能省略;stop:要返回的字符数,可以省略,返回剩余文    本。

     3.显示国家名字及其延伸词,首都是国家名字的延伸。

     select name,replace(capital,name,' ') as ext from world where capital=concat(name,'%');

     select name,mid(capital,length(name)+1) as ext from world where capital=concat(name,'%');

猜你喜欢

转载自blog.csdn.net/xiaoxiaoliluo917/article/details/80582508