In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Connection query:
Find the qualified union of the two tables with a common field. Join the two tables through a common field.
Common connections:
Inner join: match according to the common fields in the table
There are two kinds of external links: left outer link and right outer link.
1 intra-connection syntax:
Select field from Table 1 inner join Table 2 on Table 1. Field = Table 2. Field
2 intra-join: match according to the common fields in the table
Create table student (
Sid int (4) primary key auto_increment
Name varchar (50)
);
Mysql > insert into student values (1), (2)), (3)), (4))
Create a grade table: grade
Create table grade (
Id int (4) primary key auto_increment
Score varchar (20)
Sid int (4)
);
Mysql > insert into grade (score,sid) values ('1231), (' 1231)), ('1231) (5), (())
Inquire about the information of people who have achieved some results.
Mysql > select student.*,grade.* from student,grade where student.sid=grade.sid
Or:
Or:
Mysql > select student.*,grade.* from student inner join grade on student.sid=grade.sid
Or:
Mysql > select student.*,grade.* from student join grade on student.sid=grade.sid
Use table aliases to abbreviate SQL statements
Mysql > select s.journal g.* from student as s inner join grade as g on s.sid=g.sid
3 external join: all the records of a data table and the records that meet the connection conditions in another appearance.
Left connection: select field from a table left join b table on connection condition
Table an is the main table and is displayed.
B form from table
There are all the contents of the master table, and there is no real null in the slave table.
Mysql > select * from student as s left join grade as g on s.sid=g.sid
Right connection:
Select field from a table right join b table on condition
A table is from the table, both are displayed.
B table master table
Select * from student as s right join grade as g on s.sid=g.sid
The grade table is the master table, all records are displayed, and student is the slave table. The mismatch is shown in NULL
Right join, can be multi-table connection
Note: there is a join multi-table join is that the first two tables are joined after becoming a slave table, and then joined with the third table.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.