[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

MySQL: Check for douplicates

Using a MySQL query, I want to find all records from the table `zoo` where the value of `foobar`occurs exactly the same more than once.

SELECT * FROM `zoo` WHERE `foobar` IS NOT UNIQUE

Open in new window

0
hankknight
Asked:
hankknight
3 Solutions
 
HainKurtSr. System AnalystCommented:
try:

select * from zoo where id foobar in (
  select foobar FROM zoo group by foobar having count(1) > 1
)
0
 
rams4javaexpertCommented:
For counting duplicate records


SELECT COUNT(*) as repetitions, foobar FROM zoo GROUP BY foobar HAVING repetitions > 1;

For fetching all same occurance records

SELECT b.* FROM zoo a INNER JOIN zoo b ON a.foobar = b.foobar WHERE a.id <> b.id;

Here assuming id is the colum for zoo table.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
not exactly the answer, but surely you will want to read that up also:
http://www.experts-exchange.com/A_3203.html
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now