开发者

MySQL INNER JOIN syntax

开发者 https://www.devze.com 2023-04-10 12:42 出处:网络
Can someone \"break down\" the syntax here.Please.I need to learn this ASAP. From my limited experience -

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

精彩评论

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