SQL Consolidation Accumulation

Source: Internet
Author: User

 1  select  *  from  (select  *   From  dbo.xcqy2017_article where  kind=  53 ) as   T1  2  left  Span style= "COLOR: #808080" >join  (select  *  from  dbo.xcqy2017_news_classification)  As  T2 on  T2. Ncid =  t1. Ncid 
left join left link to left table Main Table
 1  select  *  from  (select  *   From  dbo.xcqy2017_article where  kind=  53 ) as   T1  2  right  Span style= "COLOR: #808080" >join  (select  *  from  dbo.xcqy2017_news_classification)  As  T2 on  T2. Ncid =  t1. Ncid 
Right- Join link to right table for main Table
1 SELECT 2      Case 3          whenKind=  -  Then 'News Update' 4          whenKind=  -  Then 'News Update'5     ELSE 'other' 6     END 'News Update 1'7,*  fromDbo.xcqy2017_article
Case-then- ELSE End condition Query

The UNION operator is used to combine the result set of two or more SELECT statements. Note that the SELECT statement inside the UNION must have the same number of columns. The column must also have a similar data type. Also, the order of the columns in each SELECT statement must be the same.

Union operator By default, the union operator chooses a different value. If duplicate values are allowed, use UNION all.

The UNION ALL operator is always the column name in the union result set equal to the column name in the first SELECT statement in the Union.

The except operator except operator derives a result table by including all rows in TABLE1 but not in TABLE2 and eliminating all duplicate rows. When all is used with EXCEPT (EXCEPT all), duplicate rows are not eliminated (it is not known if it can be done, because of the version issue, the test was unsuccessful).

Select Ncid from Dbo.xcqy2017_article EXCEPT SELECT ncid from Dbo.xcqy2017_news_classification

List all the fields in the table

NEWID () Random ID sort

SELECT * from Dbo.xcqy2017_article ORDER by NEWID ()

  

SQL Consolidation Accumulation

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.