Ich habe eine Tabelle Firma, die die Firmen-ID, Firmenname und andere Details enthält. Ich habe eine Tabelle Subunternehmer, die eine company_id Spalte hat, die company.company_id zugeordnet ist.Wie schreibe ich diese Abfrage in Linq2Sql
Wie kann ich eine Select-Anweisung schreiben, um alle aktiven Firmen zu erhalten, die keinem aktiven Subkontrakt zugeordnet sind?
select company_id
from company
where company.active_status = 1
and not exists(select * from subcontracts
where subcontracts.company = company.company_id
AND subcontracts.active_status = 1
)
ich die SQL wie schreiben würde: SELECT company_id FROM Firma c LEFT OUTER JOIN Zulieferungen sc ON c.company_id = sc.company_id UND c.active_status = 1 UND sc.active_status = 1 WHERE sc.company_id ist null – Nick