SQL statement for updating connections to the same table

Source: Internet
Author: User

Table com_resource

Create Table [DBO]. [com_resource] (
[Resourceid] [bigint] not null,
[Version] [varchar] (30) Collate chinese_prc_ci_as not null,
[Languagecode] [varchar] (10) Collate chinese_prc_ci_as not null,
[Resourcevalue] [nvarchar] (max) Collate chinese_prc_ci_as null,
[Tmpresourceid] [nvarchar] (max) Collate chinese_prc_ci_as null,
Constraint [pk_com_resource] primary key clustered
(
[Resourceid] ASC,
[Version] ASC,
[Languagecode] ASC
) With (ignore_dup_key = OFF) on [primary]
) On [primary]

Go
Set ansi_padding off

Data such

 

-- To update the tmpresourceid values of records with the same version and resourceid in the same table except languagecode = en-US and with the same resourceid to the value of the record with languagecode = en-us.

 

Update B set tmpresourceid = A. tmpresourceid
From com_resource B inner join com_resource A on B. resourceid = A. resourceid and B. languagecode = 'zh-cn'
Where a. languagecode = 'en-us'

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.