first : Internal connection

  • inner join

select   *   from   a   inner   join   b   on   a.id=b.id

  • where a.id =b.id ( This usage is very common )

select   *   from   a,b   where   a.id=b.id 

The second kind : Left and right connection

  • Left connection left join on....., The query result is all the records on the left , No record on the right table shows null
  • The right connection right join on ....., The query result is all the records on the right , The left table shows nothing null

Pictured : Right link class table , There is a class in the class 3, There are no classes in the score sheet 3 The record of , So the left table shows null

So is the left connection , Here's the picture :

Third : Next to the union and union all , Combine the two results , The difference is union all During union operation , Don't get rid of duplicate data ; Generally used for statistical query

union Used to merge two or more query results , The following conditions need to be met ( Merge by row ):

  • The same number of columns ;
  • Columns must have similar data types
  • meanwhile , Every one of them select The order of the columns in the statement must be the same

union Combine the two results , Choose a class id=1 And classes id Less than 3 Result , And show together ;( There's no duplicate data )

union all Contains duplicate data , It's convenient to see the result , The query conditions are directly the same , Be direct

True knowledge comes from practice , Do more hands-on exercises !

Inner link 、 Left and right connection 、union More articles on Union

  1. Oracle Inner link + Detailed explanation of external connection

    inner join( Internal connection ) Internal connections are also called equivalent connections , The result set returned is all the matching data in the two tables , And discard the mismatched data . in other words , In this kind of query ,DBMS Return only related rows from the source table , That is, the query result table contains two source tables ...

  2. Orcle database Tabular Built in functions Inner link External connection Related exercises

  3. Linq and SQL Left connection of 、 The right connection 、 Inner link

    Table joins are very common in our work , But there are three common ways to connect : Left connection . The right connection . Inner link In this chapter we talk about 1. How to be in Linq Use left link in , The right connection , Internal connection . 2. What are the characteristics of the three connections ? 3.Linq There are three kinds of connectives in English ...

  4. C++ Inner link External links

    When compiling ( If the compiler is VS), So the source file cpp File as a unit , Compiled into one by one obj file , And then through the linker to put different obj The files are linked up . If some variables or functions are defined as inner joins , Linkers don't use them to connect with ...

  5. Set operations —union( Combine )、intersect( intersection ) and except( Difference set )

    One . The basic format of set operations is : Set query 1 < Set operations > Set query 2 [order by ...] Two . Set operators operate on two sets , Two sets must have the same number of columns , Columns have the same data type ( At least it can hide ...

  6. sql server Use a linked server to connect Oracle,openquery Query data

      Docking problem description : I don't know the official library oracle Database account password , The other party is willing to enter the account and password on the other party's client , But don't tell us Solution : Use one sql server As an intermediate server , You can transfer data to sql serv ...

  7. VM Inside the virtual machine ubuntu Unable to connect to the network

    VM Inside the virtual machine ubuntu Unable to connect to the network solve : Edit the web , Delete all the networks . Once again join network bridging and NAT link . . Just connect again , Check it out. ip Address . Method 2: New in virtual machine ubuntu Edit virtual network , Xianhui ...

  8. Oracle In line links don't cause USER_TABLES in CHAIN_CNT Value change

    A few days ago, I discussed with netizens in the group about a link in the industry (intra-block chaining) The problem of , The question is very interesting , I happen to be free today , By the way, I sorted out these knowledge points . Problem description : below SQL, Create a more than 255 List of columns ( For the actual ...

  9. 64 position sql server How to use a linked server to connect Access

    original text :64 position sql server How to use a linked server to connect Access Test environment Operating system version :Windows Server 2008 r2 64 position Database version :Sql Server 2005 64 position ...

  10. Through the intranet , Connect dynamic ip, Intranet ip Hole digging -----p2p Realization principle ( turn )

    Source : Through the intranet , Connect dynamic ip, Intranet ip Hole digging -----p2p Realization principle

Random recommendation

  1. C++11 characteristic —— Variable part (using Type the alias 、constexpr Constant expression 、auto Type inference 、nullptr Null pointer, etc )

    #include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...

  2. status bar、navigationBar、tableView Imbibition view Set up

    1. hide navigationBar self.navigationController.navigationBar.hidden = YES; 2. status bar Set up -(void)view ...

  3. iOS The underlying Basics - File directory structure

    One :iOS Sandbox knowledge For safety reasons ,iOS The system puts every application and data in a sandbox (sandbox) Inside , The application can only access the files in its sandbox directory . Network resources, etc. ( There are exceptions. , Like the system address book . camera . Photos, etc. can be authorized by users ...

  4. SignalR Series of tutorials : Server broadcast and active data push

    This is the last of the introductory chapters in this series , Because of the working relationship , Contact SignalR I don't have a lot of time . Next time I'm free, I'll write a use “SignalR” Develop an online chat room blog series . Recently, I prefer to update the articles related to framework design , then ...

  5. Mvc Ajax Submit multiple checkbox, Also called binding and submitting select

    Ajax Mvc Of checkbox The back end has to be List<T> ,T yes ID type , commonly int or guid The model must be initialized List<T> Prevent the problem that the client does not submit any value space-time reference , Such as ...

  6. java.lang.ClassNotFoundException: com.sun.jna.Native

    In the use of sprng boot Add elasticsearch When I met java.lang.ClassNotFoundException: com.sun.jna.Native, After Baidu asked me to import <d ...

  7. Top 10 programmers flag, Do you have one ?

    2018 The end of , The long-awaited snowy day in the South has finally arrived , It's too cold ! And the joy of enjoying the snow is accompanied by cold sadness It's getting harder and harder to get up in the morning , The clothes are still cold At this time , A fabulous character to wear —— Programmers , Maybe it's going to be a sensation again ! ...

  8. Crawler module introduction --selenium ( Browser automation test tool , Simulation can call browser to simulate human operation browser )

    selenium The main purpose is to control the browser , Imitate the behavior of a real person operating a browser Module installation :pip3 install selenium Browsers that need to be controlled from selenium import webdriver ...

  9. coroutines And libco Introduce

    libco  Tencent is an open source collaborative library , It is mainly used in wechat background RPC frame , Let's start with why we use coprocessing . How to achieve collaborative process .libco Learn about coroutine and libco. why coroutines Why use coroutines , Let's start with server box ...

  10. Python The way ( Chapter five ) Python Set of basic data types 、 format 、 function

    One . Variable summary 1.1 Variable definitions Record a state or value , And use a name to represent the value or state . 1.2 The representation of variable in memory Python Everything is an object , Numbers are objects , Lists are objects , Functions are also objects , Everything is ...