Get the App
SLTechnology News&Howtos  ›  Database  › 

The realization method of establishing connection with mysql Table

Shulou Source: shulou.com Published: 2022-06-01 21:05:19 10月02日 Update

In order to reduce the limited storage space occupied by data, relational database will standardize the data into several tables, and recombine the data divided and managed is table join processing. Today Xiaobian to share with you is the implementation method of mysql table connection, many people do not know much, today Xiaobian in order to let you better understand the implementation method of mysql table connection, so give you a summary of the following content, look down together. I'm sure you'll find something.

1. inner connection

Inner join is a join method in which the primary key and foreign key between tables are connected to obtain only data with consistent key values.

Specific syntax:

Select column name 1…from table 1 inner join table 2 on table 1. foreign key = table 2. primary key [where /order by statement]

Take a chestnut:

Create class database, student and goods tables and corresponding fields, where student is the primary table, its foreign key goodsID corresponds to the primary key id of goods table, query statement (where the table name student is recorded as s, goods is recorded as g for convenience reference)

select s.name,s.phonenumber,g.name from student as s inner join goods as g on s.goodsID=g.ID;

2. Inner join of multiple tables

The following four tables are linked by setting foreign keys.

select s.name,s.phonenumber,s.sex,g.name,c.classname,a.address from ((student as s inner join goods as g on s.goodsID=g.ID)inner join classname as c on s.ID=c.ID)inner join address as a on c.ID=a.ID;

The above is a brief introduction to the mysql table establishment connection implementation method, of course, the detailed use of the above differences have to be used by everyone to understand. If you want to know more, welcome to pay attention to the industry information channel!

Tags: Data method that is database statement processing different abbreviated consistent two content multiple field way more limited see space industry grammar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi NVidia Shulou Tech Info vpn