SQL string Join function

Source: Internet
Author: User
Tags instance method join

SQL string concatenation function string concatenation function in SQL we learn to use Concat (), the syntax for Concat () is as follows: Concat (string 1, String 2, String 3, ...): string 1, String 2, String 3, and other words concatenated together. Note that Oracle's concat () only allows two parameters, in other words, only two strings can be concatenated at a time. However, in Oracle, we can use ' | | ' To concatenate multiple strings at once.

Select Region_name + ' + store_name from geography
where store_name = ' Boston ';

Instance method

A:

ID value

1 111111111

2 222222222

3 333333333


Table 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);


Method Two

SELECT *
From a
Where (substr (value, 0, 2) | | '-' || substr (Value, 2, 5) | | '-' ||
substr (Value, 8, 9)) not in (select B from data);
or update value directly

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


If not Oracle, SUBSTR replaced substring, | | Replace with +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.