开发者

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.

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 addres开发者_JS百科s 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜