PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > correct way to simulate 'except' query in mysql 4.1
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
correct way to simulate 'except' query in mysql 4.1

Réponse
 
LinkBack Outils de la discussion
Vieux 25/10/2007, 08h17   #1
Russell Uman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut correct way to simulate 'except' query in mysql 4.1


howdy.

i trying to find items in one table that don't exist in another.
i'm using a left join with a where clause to do it:

SELECT t1.field, t2.field FROM table1 t1 LEFT JOIN table2 t2 ON t1.word =
t2.word WHERE t2.word IS NULL;

both tables are quite large and the query is quite slow.

the field column is indexed in both tables, and explain shows the indexes being
used.

is there a better way to construct this kind of query?

thank you!
  Réponse avec citation
Vieux 25/10/2007, 12h26   #2
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: correct way to simulate 'except' query in mysql 4.1

Hi,

Russell Uman wrote:
>
> howdy.
>
> i trying to find items in one table that don't exist in another.
> i'm using a left join with a where clause to do it:
>
> SELECT t1.field, t2.field FROM table1 t1 LEFT JOIN table2 t2 ON t1.word
> = t2.word WHERE t2.word IS NULL;
>
> both tables are quite large and the query is quite slow.
>
> the field column is indexed in both tables, and explain shows the
> indexes being used.
>
> is there a better way to construct this kind of query?


That is the right way, but if you show us the exact output of EXPLAIN we
can more. In particular, does it say "Using distinct/not exists"
in Extra?

Baron
  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 05h09.


Édité par : vBulletin® version 3.7.4
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,07092 seconds with 10 queries