I hope it should work:

Select table1.ID from table1 left join table2 on table1.value=table2.value
where table2.value is null

OR if you want distinct IDs

Select distinct table1.ID from table1 left join table2 on
table1.value=table2.value where table2.value is null

though I didn't test it, if it does (or doesn't) let me know

Regards
Nitin

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: "Michael Stassen" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, April 29, 2004 1:15 PM
Subject: Re: SQL SELECT HELP


> Hi,
>
> Sorry. My english is not so good. :(
> I try to explain.
>
> I have table1 :
>
> ID      value
> --------------------------
> 1       100
> 1       101
> 1       102
> 1       200
> 2       100
> 2       300-------------------
> 2       310             |
> 3       100             |
>                         |
> and table2:             |
>                         |
> value                   |
> -----------                     |
> 300 <-----------------------------
>
>
> The result of the query should be from IDs of table1 (In this case 1,3) .
> The ID 2 is not allowed, because the table2 is the exception table wich is
> containing the value 300.
>
>
>
>
>
>
>
>
>
>
>
>
>
> Michael Stassen <[EMAIL PROTECTED]>
> 2004-04-28 06:13 PM
>
>
>         To:     Zoltan Gyurasits/GYO/COMP/[EMAIL PROTECTED]
>         cc:     [EMAIL PROTECTED]
>         Subject:        Re: SQL SELECT HELP
>         Classification:
>
>
>
>
>
> I'm afraid I don't understand.  From your first message, it appears you
> want
> a list of rows from table1 whose ids do not appear in table2.  The query
> Egor sent you does just that.  Did you try it?  If, as you say here, that
> isn't what you want, could you please describe what you do want?
>
> Michael
>
> [EMAIL PROTECTED] wrote:
>
> > Thanks your help, but I would like to do the following:
> >
> > If I have is ONE same ID between the two tables, than the result it must
>
> > be "empty".
> >
> > Egor Egorov <[EMAIL PROTECTED]>
> >
> > [EMAIL PROTECTED] wrote:
> <snip>
> >
> >>I have a query problem. I want to make a query....
> >>
> >>SELECT    *
> >>FROM table1
> >>INNER JOIN table2 ON table1.id NOT IN table2.id
> >>
> >>But I can't use the "NOT IN" expression here.
> >>
> >>What can i do?
> >>
> >>I have the MySQL version 4.x I can't use subquery :(
> >>
> >
> > If I've got you right you need LEFT JOIN instead of INNER JOIN.
> >
> > SELECT * FROM table1 LEFT JOIN table2
> >                  ON table1.id=table2.id
> >                  WHERE table2.id IS NULL;
>
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
>
>
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to