![]() |
Datenbank: MySQL • Version: 5.1 • Zugriff über: PHP
[SQL] Welche Nutzer gehören nicht zu Projekt?
Hallo,
ich habe mal wieder ein Problem mit meiner SQL Abfrage. Ich möchte alle Benutzer ermitteln, die nicht einem bestimmten Projekt (hier mit project_id 1) zugeordnet sind. Die folgende Abfrage schmeißt aber alles raus:
SQL-Code:
Die Tabellenstruktur:
SELECT sds_users.id, sds_users.lastname, sds_users.firstname FROM sds_users
left join sds_users2projects on sds_users.id = sds_users2projects.user_id AND sds_users2projects.project_id !=1 sds_users: id | lastname | firstname sds_users2projects: id | user_id | project_id Viele Grüße ... |
Re: [SQL] Welche Nutzer gehören nicht zu Projekt?
SQL-Code:
SELECT
u.id, u.lastname, u.firstname FROM sds_users u where u.id not in ( select userid from sds_users2projects where project_id = 1) |
Re: [SQL] Welche Nutzer gehören nicht zu Projekt?
SQL-Code:
Ist zwar schnell runtergetippt, sollte aber auch gehen :wink:
SELECT sds_users.id, sds_users.lastname, sds_users.firstname FROM sds_users
JOIN sds_users2projects ON sds_users.id = sds_users2projects.user_id WHERE sds_users2projects.project_id != 1 |
Re: [SQL] Welche Nutzer gehören nicht zu Projekt?
geht
NOT a=1 AND NOT a IS NULL ? |
Re: [SQL] Welche Nutzer gehören nicht zu Projekt?
Hi,
@mkinzler: Das passt! :thumb: Zitat:
Viele Grüße ... |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:24 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