Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Returning All Rows That Repeat

From: Gary Josack <gary(at)byoteki.com>
Date: Sun Jul 29 2007 - 21:18:07 EDT


John Kopanas wrote:
> I want to be able to return all rows that have one or more other rows
> with the same customer_number and job_number.
>
> So for instance. If their are two jobs in my jobs table with a
> customer_number = '0123' and job_number ='12' then I want both of
> those jobs to return one right after another so I can compare their
> other fields. And I want to run a query once a day over the whole
> table to see if their are any repeats.
>
> Does anyone have a clue how to do this?
>
> Thanks :-)
>
> Your Friend,
>
> John
>
>

Not sure how to do this with one command right now because i'm tired and cant think straight but heres one way:

create temporary table tempjobdupes as select customer_number, job_number from jobs group by customer_number, job_number having count(*) >1;
select * from jobs where (customer_number, job_number) = any (select * from tempjobdupes);
drop table tempjobdupes;

theres got to be another way but the subqueries i'm trying aren't working how i want. If i think of anything else i'll try again. Let me know how this works for you.

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Sun Jul 29 21:19:05 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 09 2007 - 19:29:34 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library