Home > Database > Mysql Tutorial > sql 字符串连接函数

sql 字符串连接函数

WBOY
Release: 2016-06-07 17:47:52
Original
1695 people have browsed it

sql 字符串连接函数在sql中字符串连接函数我们学用到CONCAT()来,CONCAT() 的语法如下:CONCAT(字串1, 字串2, 字串3, ...): 将字串1、字串2、字串3,等字串连在一起

sql 字符串连接函数在sql中字符串连接函数我们学用到concat()来,concat() 的语法如下:concat(字串1, 字串2, 字串3, ...): 将字串1、字串2、字串3,等字串连在一起。请注意,oracle的concat()只允许两个参数;换言之,一次只能将两个字串串连起来。不过,在oracle中,我们可以用'||'来一次串连多个字串。

select region_name + ' ' + store_name from geography
where store_name = 'boston';

 

实例方法

a:

id value

1 111111111

2 222222222

3 333333333


表 b:

id data

9 11-11111-11

10 22-22222-22

11 33-33333-33

 

select * from a where substring(value,1,2) + '-' + substring(value,3,5) + '-' + substring(value,8,2)

not in (select b from data);


方法二

select *
from a
where (substr(value, 0, 2) || '-' || substr(value, 2, 5) || '-' ||
substr(value, 8, 9)) not in (select b from data);
或者直接更新value

update a set value=(substr(value, 0, 2) || '-' || substr(value, 2, 5) || '-' ||
substr(value, 8, 9));


如果不是oracle 的话substr 换成substring ,||换成+

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template