Thank you very much.
Works perfectly now.

-----Ursprüngliche Nachricht-----
Von: Harald Fuchs [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 15. Juli 2004 13:58
An: [EMAIL PROTECTED]
Betreff: Re: query w multiple tables and expressions

This gives all hotels having at least one of the required
services/sparetimes, i.e. an OR condition.  For AND you need

SELECT stammdaten.id_PK
FROM stammdaten
INNER JOIN relation_services ON stammdaten.id_PK = relation_services.hotelid
INNER JOIN relation_sparetime ON stammdaten.id_PK =
relation_sparetime.hotelid WHERE stammdaten.location = 'Bern'
  AND relation_services.serviceid IN (5, 3, 7)
  AND relation_sparetime.sparetimeid IN (2, 5)
GROUP  BY stammdaten.id_PK
HAVING count(DISTINCT relation_services.serviceid) >= 3
   AND count(DISTINCT relation_sparetime.sparetimeid) >= 2 ORDER  BY
stammdaten.id_PK


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

Reply via email to