简体   繁体   English

MySQL INNER JOIN语法

[英]MySQL INNER JOIN syntax

Can someone "break down" the syntax here. 有人可以在这里“分解”语法吗? Please. 请。 I need to learn this ASAP. 我需要尽快学习。

From my limited experience - 根据我有限的经验-

firstname and lastname are columns and list is a table. firstnamelastname是列, list是表。

count(id)>1 is used to check if there is more than one row with the same... count(id)>1用于检查是否有多条相同的行...

That's it. 而已。 I don't know what this does but I need to understand it. 我不知道这是做什么的,但我需要了解它。

SELECT firstname, lastname, list.address FROM list 
INNER JOIN (SELECT address FROM list 
            GROUP BY address 
            HAVING count(id) > 1) dup 
   ON list.address = dup.address

This query will return a list of all names (first and last name), which contain a duplicate address. 该查询将返回所有名称(名字和姓氏)的列表,其中包含重复的地址。 This part 这部分

SELECT address FROM list 
GROUP BY address HAVING count(id) > 1

Gets a list of all the addresses that occur more than once in the table, This is then joined back to the table itself, to return all names which have the same address. 获取表中多次出现的所有地址的列表,然后将其联接回表本身,以返回具有相同地址的所有名称。 This should return a list of all the unique address which have more than 1 name associated with them, along with the names that go along with the addresses. 这应该返回所有唯一名称的列表,这些唯一名称具有多个与之相关联的名称,以及与该地址一起使用的名称。

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

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