PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.database.mysql > Finding Duplicates
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Finding Duplicates

Réponse
 
LinkBack Outils de la discussion
Vieux 11/07/2006, 03h21   #1
duende
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Finding Duplicates

I was hoping someone will be able to me, i've got a bit of
experience with mysql, but nothing quite like this.

I have a table with 3 columns 'sid', 'aid', and 'call'.

What i want to do is to create a query that shows me all records where
sid matches and aid matches but call differs.

For example, it would give me this result:

sid aid call
abc def gh
abc def ij

and not:

sid aid call
abc def gh
abc def gh

Currently i have a query that gives me all matches of sid's and aid's
but gives me call's that match and don't match.

I hope this is not too confusing, I'm really lost at this point. Thank
you.

  Réponse avec citation
Vieux 11/07/2006, 05h33   #2
duende
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding Duplicates

I seem to be very close now, here is what I have:

select a.sid, a.aid, a.call from raw as a, raw as b where a.aid=b.aid
and a.sid=b.sid and a.call != b.call;

This appears to work ( hard to verify fully due to over 100,000
records), however, one part that doesn't work is that if there are two
records with matching sid's and aid's but one of the call's are blank,
it won't pick it up. You would think that comparing two values, if one
has a value, and the other one doesn't, they wouldn't match.


duende wrote:
> I was hoping someone will be able to me, i've got a bit of
> experience with mysql, but nothing quite like this.
>
> I have a table with 3 columns 'sid', 'aid', and 'call'.
>
> What i want to do is to create a query that shows me all records where
> sid matches and aid matches but call differs.
>
> For example, it would give me this result:
>
> sid aid call
> abc def gh
> abc def ij
>
> and not:
>
> sid aid call
> abc def gh
> abc def gh
>
> Currently i have a query that gives me all matches of sid's and aid's
> but gives me call's that match and don't match.
>
> I hope this is not too confusing, I'm really lost at this point. Thank
> you.


  Réponse avec citation
Vieux 11/07/2006, 18h58   #3
Bill Karwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding Duplicates

duende wrote:
> I seem to be very close now, here is what I have:
>
> select a.sid, a.aid, a.call from raw as a, raw as b where a.aid=b.aid
> and a.sid=b.sid and a.call != b.call;
>
> This appears to work ( hard to verify fully due to over 100,000
> records), however, one part that doesn't work is that if there are two
> records with matching sid's and aid's but one of the call's are blank,
> it won't pick it up. You would think that comparing two values, if one
> has a value, and the other one doesn't, they wouldn't match.


That behavior has been part of the standard SQL language forever. The
idea is that NULL is the absence of a value, so how can we know if it is
equal or unequal to anything?

"What's Bill's birthday?"
"I don't know."
"Is it the same as Duende's birthday?"
"I can't say for certain."

Anyway, you could try this alternative:

select a.sid, a.aid, a.call
from raw as a, raw as b
where a.aid=b.aid and a.sid=b.sid and (a.call != b.call or a.call IS
NULL or b.call IS NULL);

Regards,
Bill K.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h03.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09473 seconds with 11 queries