At 16:02 17.07.01 +0100, Glenn Wearen wrote:
> > select distinct PersonID
> > from PersonProject
> > where ProjectID != '2';
> >
> > Is this what you are looking for?
>
>
>No, what I'm looking for is...
>SELECT PersonID
>FROM PersonProject
>AND PersonID NOT IN (SELECT PersonID
> FROM PersonProjectID
> WHERE ProjectID='2')
>
>But this can't be done in MySQL, so does anybody know a work-around?
>
Hi,the problem is, that mysql can not nested selects.
I have make a work around in php.
First I make a list with e.g ids like that ('3','4','5') and then the
SELECT TABLE.id_field NOT IN ('3','4','5')
here the script in php in eine classe eingebaut.
$da = explode ("-",$datum);
$q = sprintf ("select lkwangemeldetid from disposition where
dayofmonth(datumderdisposition) =%d and month(datumderdisposition)=%d and
year (datumderdisposition)= %d",$da[2],$da[1],$da[0]);
$this->qdc->query ($q);
$liste="''";
while($this->qdc->next_record())
{
if ($liste == "''")$liste ="";
$liste.=sprintf ("'%s',",$this->qdc->f(lkwangemeldetid));
}
if ($liste != "''")
$liste=substr($liste,0,-1);
return $liste;
>Original question follows...
> > How can I get a list of all PersonID's who are not in
> > ProjectID 2 (i.e.
> > PersonID 3 and 4)?
> >
> > Table: PersonProject
> >
> > PersonID | ProjectID
> > -------------------
> > 1 | 1
> > 2 | 1
> > 3 | 1
> > 1 | 2
> > 2 | 2
> > 1 | 3
> > 2 | 3
> > 3 | 3
> > 4 | 3
> >
> >
> > BTW "SELECT PersonID from PersonProject where ProjectID !=
> > '2'" doesn't work
> >
> >
> > ---------------------------------------------------------------------
> > 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
> >
>
>---------------------------------------------------------------------
>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
BLITZ Internet Service GmbH
Kronacher Strasse 41
D-96052 Bamberg, Germany
Tel. +49/951/9685160, Fax +49/951/9685164
http://www.blitz.net
---------------------------------------------------------------------
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