For analysis, we need to integrate some data into a table, which involves associating multiple tables with the primary key to obtain the values of some of the fields. We can simply implement it through update. I found an article, pretty good:
When updating tables in batches, when updating columns in a table, you must depend on another table. This dependency can b
ObjectiveThis section begins with our join learning, about connecting this piece involves more content, we step by step learning, short content, in-depth understanding.Crossover join (Cross join)Cross joins are the simplest type of join. A cross join performs only one logica
customer service department, 20% of the customers are obtained through the active serviceCity and other accurate information, so you extract this part of information to a temporary table:
SQL code
Createtable tmp_cust_city
(
Customer_id number (8) notnull,
Citye_name varchar2 (10) notnull,
Customer_type char (2) notnull
)
1) The simplest form
SQL code
-- It is confirmed that all the mermer_id
SQL inline syntax basic syntax (innerjoin) SELECT * FROM Table 1innerjoin table 2on table 1. userid table 2. useridsql inline syntax description: The preceding statement is used to query two tables, table 1 and table 2. If the userid fields in the two tables are the same, a row is displayed. 45it.com Note: The preceding syntax is equivalent to select * from table
is not satisfied, because the supplier code is really meaningless to humans, join can help at this time. By joining the suppliers table, we can query the Supplier name.
Select productid, productname, suppliers. supplierid, suppliers. companyName from products inner join suppliers on products. supplierid = suppliers. supplierid order by productname
Outer Join
Th
Objective
At the beginning of this section we entered the join learning, about the connection of this piece of content more, we step-by-step study, short content, in-depth understanding.
Cross join (CROSS join)
Cross joins are the simplest type of join. A cross join perfo
information as follows:SELECT a.*,b.* from Luntan left JOIN usertable as B on A.username=b.usernameAll the authors in the city table and all the authors in the user table, and the cities in which they are located, are used with the full outer join:SELECT a.*,b.* OUTER JOIN user as B on a.username=b.username(iii) Cross-linkingThe cross join does not take a WHERE
The following are their commonalities: 1. Concepts about left and right tables. The left table refers to the table on the left of left join in the SQL statement, and the right table refers to the table on the right of left join.
2. In a large table, the left table is placed on the left, and the right table is placed on
Passe.id = Ee.passengerid left JOIN (passenger Pass left JOIN ' user ' U on pass.stuffuuid = U.id) on Pass.id = Ee.passengerid left JOIN (passenger Passen Left join (Airticketorder AO left join (' user ' UA left JOIN company comp
1. Join has left Join,right Join,inner join these three kinds, two tables do a Cartesian product, and then select the result set, select the part that satisfies the condition as the result.
Join (INNER
Tags: Oracle hash join leading table Use_hashHash joins (hash join) is a table join method in which two tables rely primarily on hashing to obtain a concatenated result set when making a table connection.For a sort merge connection, if the result set of the two tables is lar
the configuration class that can be used to set the key value of the sort group.4. SummaryTo summarize, the core of join is the small table memory can be put down, can put down the map joinNot fit, reduce join.Reduce joins a large amount of network and disk IO, with poor performance and a way to optimize: method One : Semi-join, map filter join demand column
contained in the category.
Select count (P. ID), C. category_name from post P rightjoin category C on p. PID = C. cid3. inner join
(Identify the rows associated with the two tables) query logs with the same category. (That is, log articles that are not classified will not be within the scope of our query ).
Select P. Title, C. category_name from post P inner join
How can we query the information of different tables together when we talk about the inefficiency of the related sub-queries in the previous blog post? This requires a table join.Unlike the previous union query, the Union combines different tables, that is, vertical joins, which are spelled upright.A table join is a horizontal
The following is a test example.1. Create two temporary tables and input test data:Copy codeThe Code is as follows:Create table # temptest1(Id int,Name1 varchar (50 ),Age int)Create table # temptest2(Id int,Name1 varchar (50 ),Age int)
The following table data is queried:
# Temptest1 # temptest2
2. Now we need to update the age in # temptest2 to the corresponding age in # temptest1.
In fact, the age of I
The left join is a left table datum, showing all the coordinates of the row, the right table and the left table associated with the data will be displayed, not associated is not displayed. The keyword is left join on. * * Basic usage is as follows:Select Table Left Join Table on = b.ta_id* *Note: 1?? Where on the associated field should be the same field (the f
database stores matching rows in B in tempdb. If the next row in a is the same, the content in tempdb is read; otherwise, the data in tempdb is deleted.2.3 comparison between one-to-least and others-to-leastObviously, one-to-one sequence is more efficient because it does not need a temporary table. So how can we let the query optimizer know that one of our sets is unique. The first method is to create a clustered index, and the second is the distinct and group by operators.
3 sorting and Inde
Mysql tutorial detailed description of left join SQL left join statementsMysql left join query is a method of joint query. That is to say, two related tables are joined together for query in this way, which makes it easier to call data and avoids multi-layer loop nesting.
Le
Tags: oracle merge sort Jo Use_mergeSort merge joins (sort merge join) are two tables that use the sort operation (sort) and merge operation (merge) to get the connection method of the result set when making a connection.The pros and cons of a sort merge connection and the scenarios that apply are as follows:A, typically, a sort merge connection performs much less efficiently than a hash connection, but the
Use left join and inner join in SQL.
Left join on is a left Outer join. The data is based on the table on the left. The table data on the right is queried even if it is null,
Inner join on means that the data in the
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.