>Hello,
>
>I have a problem composing a sql-statement for my special needs.
>I hope anybody can help me.
>
>
>This is the situation:
>
>I have 2 tables, a and b as following:
>
>--------------
>| a |
>--------------
>| eid | name |
>--------------
>
>
>------------------
>| b |
>------------------
>| id | gid | eid |
>------------------
>
>*) a.eid and b.id are primary keys
>
>*) b.eid points to a.eid entries
>
>
>Now my wish:
>
>*) b.gid = fixed given value
>
>*) i want all entries from a , which are NOT referenced by any entries
>from b.eid where b.gid = fixed given value
>
>Is this possible with only one sql-statement?
>
>-
>
>I have tried over and over, but didn't get a correct sollution.
>
>One of my tries was:
>
> select a.eid from a,b where b.gid = <fixed> and a.eid != b.eid
>
>but it didn't work out.
>
>
>Any help is welcome! THX
>
>--
>greetings - WEMMER Alexander <[EMAIL PROTECTED]>
Sir, you want to join a and b and return all rows from a, so you want
an outer join.
SELECT a.*
FROM a LEFT JOIN b ON a.eid = b.eid
Then you want to remove any rows from this join where b.gid equals a
given value.
WHERE b.gid != <value>;
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak
MySQL list magic words: sql query database
---------------------------------------------------------------------
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