SQL-Monster

Irgendwie kann man sich das Leben auch schwer machen und solche Abfragemonster bauen, nur um zu erfahren, welche Software aktuell einem bestimmten PC NICHT zugeordnet ist.

(SELECT DISTINCT software.name as nm, software.id as soft FROM software, software_pc WHERE software.id=software_pc.sid and pcid=16 GROUP by nm, soft HAVING count(datum)=count(ende))
UNION DISTINCT
(SELECT DISTINCT software.name as nm, software.id as soft FROM software LEFT JOIN software_pc ON software.id=software_pc.sid WHERE sid is null)
UNION DISTINCT
(SELECT software.name as nm, software.id as soft FROM software WHERE software.id not in (SELECT software.id FROM software, software_pc WHERE software.id=software_pc.sid and software_pc.pcid=16))
ORDER BY nm;

Naja, wenigstens scheint es zu klappen..