![]() |
Re: SQL ADS und ungleich
Zitat:
SQL-Code:
oder:
SELECT * FROM CONTACTS LEFT JOIN PROJECTS_TO_CONTACTS ON CONTACTS.ID = PROJECTS_TO_CONTACTS.CONTACT_ID
WHERE ((not (PROJECTS_TO_CONTACTS.PROJECT_ID=4)) OR (PROJECTS_TO_CONTACTS.PROJECT_ID IS NULL))
SQL-Code:
Der Vergleich auf <> funktioniert bei einigen Datenbanken nicht ordentlich, wenn von ihm auch Spalten mit Null-Werten betroffen sind.
SELECT * FROM CONTACTS LEFT JOIN PROJECTS_TO_CONTACTS ON CONTACTS.ID = PROJECTS_TO_CONTACTS.CONTACT_ID
WHERE ((PROJECTS_TO_CONTACTS.PROJECT_ID not in(4)) OR (PROJECTS_TO_CONTACTS.PROJECT_ID IS NULL)) Hast Du bei Deiner Datenbank eine IsNull- oder IfNull-Funktion? Dann könnte Dir auch sowas helfen:
SQL-Code:
Hoffe, dass ich Dein Problem verstanden habe und nicht jetzt den Lösungsansatz für ein anderes Problem liefere.
SELECT * FROM CONTACTS LEFT JOIN PROJECTS_TO_CONTACTS ON CONTACTS.ID = PROJECTS_TO_CONTACTS.CONTACT_ID
WHERE ((IsNull(PROJECTS_TO_CONTACTS.PROJECT_ID,-1) <> 4)) |
Re: SQL ADS und ungleich
Nur so als Idee:
Warum setzt du nicht PROJECT_ID auf default not null bzw. default -1 ? :hi: |
Re: SQL ADS und ungleich
Hallo,
ich zitier mich mal: Zitat:
Viele Grüße ... |
Re: SQL ADS und ungleich
Zitat:
SQL-Code:
select a.* from #contacts a
where a.id not in (select b.contact_id from #projects_to_contacts b where b.project_id=4 ) |
Re: SQL ADS und ungleich
Hallo Joachim,
ich bekommme da eine Fehlermeldung, das er die Tabelle nicht findet?: Zitat:
// Edit. Ich glaub so geht's:
SQL-Code:
select a.* from contacts as a
where a.id not in (select b.contact_id from projects_to_contacts as b where b.project_id=4 ) |
Re: SQL ADS und ungleich
Er hat wahrscheinlich die Testdaten in temporären Tabellen angelegt (Präfix #). ADS löscht solche Tabellen beim Schließen der DB-Connection automatisch.
|
Re: SQL ADS und ungleich
Hi,
Zitat:
:cheer: :dp: :cheer: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz