try the left join:
select MYTABLE.* from MYTABLE left join ANOTHERTABLE on MYTABLE.entry = ANOTHERTABLE.entry where ANOTHERTABLE.entry is NULL; -----Original Message----- From: Ian Harisay [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 10, 2002 8:10 AM To: [EMAIL PROTECTED] Subject: Re: mysql query Actually an outer join may not work either. So you simply do: $sth = $dbh->prepare("SELECT entry FROM anothertable"); $sth->execute; while ( ($entry) = $sth->fetchrow_array() ){ push( @entries, $entry ); } $sth->finish; $sth = $dbh->prepare("SELECT * FROM mytable"); $sth->execute; ## this is an example of printing the records. while ( $rec = $sth->fetchrow_hashref() ){ my $entry = $rec->{entry}; ## did this just to simplify our grep. next if ( grep /^$entry$/, @entries ); print &stringHash( $rec ); ## a subroutine for printing a hash in a pretty format. } $sth->finish; Ian Harisay wrote: > > I don't believe MySQL supports sub queries yet. I could be wrong. I would > double check this on MySQL.com Make sure you check against the version you have > installed. The other piece of your puzzle requires an outer join. > > Andrey wrote: > > > > Hi all, > > > > What is wrong with this query: > > > > select * from MYTABLE where MYTABLE.entry NOT IN (select ANOTHERTABLE.entry from ANOTHERTABLE) > > > > mysql gives me a sintax error that looks like this: > > > > ERROR 1064: You have an error in your SQL syntax near 'select ANOTHERTABLE.entry from ANOTHERTABLE)' at line 1 > > > > does mysql support complex queries? > > is there any way to select something from one table that IS NOT in the other? > > I tried stuff like joining two tables (MYTABLE and ANOTHERTABLE) and > > putting conditions : > > > > MYTABLE.entry != ANOTHERTABLE.entry > > > > but that does not work for some reason. > > > > Also, keep in mind that MYTABLE.entry and ANOTHERTABLE.entry both of the type varchar(50) > > > > thanks in advance, > > > > Andrey
