AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken [MySQL] Problem mit LEFT JOIN
Thema durchsuchen
Ansicht
Themen-Optionen

[MySQL] Problem mit LEFT JOIN

Ein Thema von 3_of_8 · begonnen am 28. Mai 2007 · letzter Beitrag vom 28. Mai 2007
Antwort Antwort
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#1

[MySQL] Problem mit LEFT JOIN

  Alt 28. Mai 2007, 12:43
Datenbank: MySQL • Zugriff über: PHP-MySQL-Extension
Morgen.

Ich habe zwei Tabellen, die in einer 1:n-Relation stehen.

Ich möchte jetzt alle Zeilen aus der ersten Tabelle, für die eine Zeile in der zweiten Tabelle existiert mit dem Wert wuppdi<>2 oder keine Zeile in der zweiten Tabelle existiert. Die beiden Tabellen sind über den Wert von id1 vernküpft.

tabelle1:
id1: INT(11) (Schlüssel)

tabelle2:
id2: INT(11) (Schlüssel)
id1: INT(11)
wuppdi: TINYINT(1)

Mein Versuch:

SELECT * FROM tabelle1 LEFT JOIN tabelle2 USING (id1) WHERE wuppdi=NULL OR wuppdi<>2
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
Benutzerbild von Jelly
Jelly

Registriert seit: 11. Apr 2003
Ort: Moestroff (Luxemburg)
3.741 Beiträge
 
Delphi 2007 Professional
 
#2

Re: [MySQL] Problem mit LEFT JOIN

  Alt 28. Mai 2007, 13:18
Versuchs mal so:

SQL-Code:
SELECT * FROM tabelle1 t1 LEFT JOIN tabelle2 t2 on t2.id1=t1.id1
WHERE t2.wuppdi=NULL OR t2.wuppdi<>2
  Mit Zitat antworten Zitat
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: [MySQL] Problem mit LEFT JOIN

  Alt 28. Mai 2007, 13:33
Leider auch nicht, leeres Ergebnis.

Übrigens: Wenn ich die letzte Bedingung weglasse, also nur diesen Query mache...

SQL-Code:
SELECT * FROM tabelle1 t1 LEFT JOIN tabelle2 t2 on t2.id1=t1.id1
WHERE t2.wuppdi=NULL
...dann bekomme ich auch kein Ergebnis. Offenbar erkennt er die nicht vorhandenen Einträge nicht als NULL, obwohl sie, wenn ich die WHERE-Klausel ganz weglasse, als NULL angezeigt werden.
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
Benutzerbild von Jelly
Jelly

Registriert seit: 11. Apr 2003
Ort: Moestroff (Luxemburg)
3.741 Beiträge
 
Delphi 2007 Professional
 
#4

Re: [MySQL] Problem mit LEFT JOIN

  Alt 28. Mai 2007, 13:36
Ich bin aber auch ein Depp Auf null prüft man ja auch anders:
SQL-Code:
SELECT * FROM tabelle1 t1 LEFT JOIN tabelle2 t2 on t2.id1=t1.id1
WHERE t2.wuppdi is NULL OR t2.wuppdi<>2
sollte aber gehen
  Mit Zitat antworten Zitat
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#5

Re: [MySQL] Problem mit LEFT JOIN

  Alt 28. Mai 2007, 14:23
Das tut es. Danke.
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:13 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz