MySQL Query help
Hi there, I'm pretty new to mysql. I'm trying to make a query concerning 2 given tables.
Destination:
| Letter-ID | Destination-Country | [..] and
Addresser:
| Letter-ID | Addresser-ID | [..]
Letter-ID and Addresser-ID are unique.
I'm trying to list all addressers (Addresser-ID) who have been writing to addressees in at least 2 different countries. The countries should be in the list, too:
| Addresser-ID | Destination-Country |
| 1 | England |
| 1 | Denmark |
| 1 | Portugal |
| 3 | England |
| 3 | India |
...
Right now, I've no access to the database, but I'm trying to work out a query.
SELECT addresser-id, destination-country
FROM destination a INNER JOIN addresser b ON ( a.letter-id = b.letter-id)
GROUP BY addresser-id, destination-country
HAVING COUNT(addresserid) > 1;
I'm not sure, if the inner join solution (if working) is the best way to do it. Somebody got a better idea?
Thanks in advance.
Subject
Written By
Posted
MySQL Query help
June 27, 2012 08:53AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.