Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The realization method of establishing connection with mysql Table

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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!

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.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report