MySQL INNER JOIN语法 [英] MySQL INNER JOIN syntax
问题描述
有人可以在这里分解"语法吗?请.我需要尽快学习.
Can someone "break down" the syntax here. Please. I need to learn this ASAP.
根据我的有限经验-
firstname
和lastname
是列,而list
是表.
count(id)>1
用于检查同一行中是否存在多于一行...
count(id)>1
is used to check if there is more than one row with the same...
就是这样.我不知道这是做什么的,但我需要了解它.
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.
这篇关于MySQL INNER JOIN语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!