List:General Discussion« Previous MessageNext Message »
From:Philippe Poelvoorde Date:July 9 2004 3:51pm
Subject:Re: anyone help with this query? Returning tooooo many results
View as plain text  
 From the documentation

mysql> SELECT table1.* FROM table1
     ->        LEFT JOIN table2 ON table1.id=table2.id
     ->        WHERE table2.id IS NULL;


will normally give you the right answer.
and you should get : 2026  x 240 - 486,057 = 183 results

Aaron Wolski wrote:

> Hi all,
> 
> Having a problem with a query that's returning 486,057 results when it
> most definitely should NOT be doing that.
> 
> I have two tables:
> 
> 1 for a list of customers that purchase product A, another for customers
> who purchased product B.
> 
> Columns are:
> 
> Id
> First
> Last
> Email
> 
> I am trying to compare table 1 to table 2 to get a result set that gives
> me the contact info (table columns) for those whose email addresses in
> table 1 DON'T EQUAL those in table two.
> 
> In table one I have 2026 records
> In table two I have 240 records
> 
> The query is this:
> 
> SELECT * FROM producta_customers AS t1, productb_customers AS t2 WHERE
> t1.email != t2.email
> 
> When I do this query. I get 486,057 results returne.
> 
> Where am I going wrong? Any ideas?
> 
> Thanks so much for the help!
> 
> Aaron
> 
> 
> 


-- 
Philippe Poelvoorde
COS Trading Ltd.
+44.(0)20.7376.2401
philippe@stripped
Thread
anyone help with this query? Returning tooooo many resultsAaron Wolski9 Jul
  • Re: anyone help with this query? Returning tooooo many resultsMartijn Tonies9 Jul
  • Re: anyone help with this query? Returning tooooo many resultsAlec.Cawley9 Jul
  • Re: anyone help with this query? Returning tooooo many resultsPhilippe Poelvoorde9 Jul
RE: anyone help with this query? Returning tooooo many resultsVictor Pendleton9 Jul
Re: anyone help with this query? Returning tooooo many resultsSGreen9 Jul
  • RE: anyone help with this query? Returning tooooo many resultsAaron Wolski9 Jul
RE: anyone help with this query? Returning tooooo many resultsSGreen9 Jul
  • RE: anyone help with this query? Returning tooooo many resultsAaron Wolski9 Jul