简体   繁体   English

我想联接数据库中的两个表

[英]I want to join two tables in my database

I search in internet but i want some more sufficient answer. 我在互联网上搜索,但我想要更多的答案。 when i join a full of rows table in my database with an empty table from the same database. 当我将数据库中的完整行表与同一数据库中的空表联接在一起时。 All the rows, from the full of rows table, will create also in the empty table?? 从完整的行表开始,所有行也将在空表中创建? That is the purpose of a join two tables? 那是联接两个表的目的吗?

if you want to display either one of the table even if the other table is empty, then use left or right join . 如果要显示其中一个表,即使另一个表为空,则请使用left or right join

INNER JOIN 内部联接

This is the simplest, most understood Join and is the most common. 这是最简单,最容易理解的Join,也是最常见的。 This query will return all of the records in the left table (table A) that have a matching record in the right table (table B) 该查询将返回左表(表A)中所有与右表(表B)中具有匹配记录的记录。

LEFT JOIN 左联接

This query will return all of the records in the left table (table A) regardless if any of those records have a match in the right table (table B). 该查询将返回左表(表A)中的所有记录,无论这些记录中的任何一条在右表(表B)中是否匹配。 It will also return any matching records from the right table. 它还将从右表中返回所有匹配的记录。

RIGHT JOIN 正确加入

This query will return all of the records in the right table (table B) regardless if any of those records have a match in the left table (table A). 该查询将返回右表(表B)中的所有记录,无论这些记录中的任何一条在左表(表A)中是否匹配。 It will also return any matching records from the left table 它还将返回左侧表中的所有匹配记录

Here's the complete guide 这是完整的指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM