Quoting Bruce Feist <[EMAIL PROTECTED]>:

> Phil Dowson wrote:
> 
> >>Looks like a syntax error to me.  There is no t1id in t2.  Also, the OR 
> >>is redundant; if no t2 row was found, both t2id and t2gid will be NULL, 
> >>so checking one of them suffices.  Try
> >>
> >>SELECT t1.t1id
> >>  FROM t1 LEFT JOIN t2 ON t1.t1id = t2.t2id
> >>  WHERE t2.t2id IS NULL;
> >>
> >Thanks for your help, but its not quite what I needed. I had managed to get
> that
> >far, but the problem is that I want it to display the following:
> >
> >when t2.t2id exists and t2.t2gid exists display t1.t1id
> >when t2.t2id exists but t2.t2gid doesnt exist display nothing
> >
> >Does that make it any clearer? I am still a novice at SQL, and I'm trying to
> get
> >used to MySQL and MSSQL at the same time (I need MSSQL for work)
> >  
> >
> OK.  I'm not sure why you were originally looking at "NOT IN", then; I'm 
> worried that I may still be misunderstanding something.  To get what 
> you're describing, try
> 
> SELECT t1.t1id
>   FROM t1 INNER JOIN t2 ON t1.t1id = t2.t2id
>   WHERE t2.t2gid IS NOT NULL;
> 
> Bruce
> 
> 
> 
Bruce,

I modified

> SELECT t1.t1id
>   FROM t1 INNER JOIN t2 ON t1.t1id = t2.t2id
>   WHERE t2.t2gid IS NOT NULL;

to work closer to what I need,

SELECT t1.t1id 
FROM t1 
LEFT JOIN t2 ON t1.t1id = t2.t2id 
WHERE t2.t2gid <> 192  //an example of a gid I am using//

This is close, it shows all the id's that exist in the t2 table without a
t2.t2gid of 192, but I also need to show all t1.t1id's that exist in the t1
table that do NOT exist in t2.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to