Autor Beitrag
tortom1000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175

Win XP, Win Server 2003 - 2012, Win 7
Delphi 7
BeitragVerfasst: Mi 10.05.06 09:39 
Hi,
vereinfacht dargestellt:

ich hab 'ne Tabelle mit den Spalten Name,Datum und Bild. Es gibt Datensätze, welche im
Feld Bild keine Einträge habe. Die anderen enthalten den Verzeichnispfad mit Bildname,
z.b. c:\bilder\test.jpg.
Ich hätte gerne die SQL-Abfrage so modifiziert, das mir nur die Datensätze geliefert werden, welche im Feld Bild irgendetwas stehen haben, also nicht leer sind.

Wie muss ich diese Abfrage anpassen, damit es wie gewünscht funktioniert?
'SELECT * FROM tabelle WHERE NAME = ' + auswahlID + ' And BILD= ' + ' Order By DATUM'

Grüße
Tortom
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 10.05.06 09:43 
Normalerweise musst du nur prüfen, ob der Inhalt "NOT NULL" ist. Wenn allerdings mal was drin stand und du das Feld geleert hast, musst du einfach auf Leerstring ('') prüfen.
Je nach Datenbank kannst du das in eine Bedingung (Oracle, kennt eine Konvertierung: nvl) einbauen. Ansonsten musst du zwei Bedingungen prüfen.
tortom1000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175

Win XP, Win Server 2003 - 2012, Win 7
Delphi 7
BeitragVerfasst: Mi 10.05.06 10:18 
Wie muß ich das NOT NULL denn (bei einer Firebird-Datenbank) einbauen?
Der unten stehende Versuch verursacht bei mir den Fehler "Variante des Typs (NULL) konnte nicht in TYP (String) konvertiert werden."
'SELECT * FROM tabelle WHERE NAME = ' + auswahlID + ' And BILD= '+ NOT NULL + ' Order By DATUM'
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 10.05.06 10:26 
afair meine ich, dass das so aussehen muss:
ausblenden Delphi-Quelltext
1:
'SELECT * FROM tabelle WHERE NAME = ' + auswahlID + ' And BILD IS NOT NULL Order By DATUM'					

Ich habe hier aber kein Firebird zur Verfügung und kann es daher nicht testen.
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Mi 10.05.06 10:26 
Die Überprüfung auf ein leeres Feld geht mit IS NULL bzw. IS NOT NULL:

'SELECT * FROM tabelle WHERE name = ' + auswahlID + 'AND bild IS NOT NULL ORDER BY datum'

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
tortom1000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175

Win XP, Win Server 2003 - 2012, Win 7
Delphi 7
BeitragVerfasst: Mi 10.05.06 11:36 
Ich hab's euren Tips entsprechend eingebaut und es funktioniert astrein...
Vielen Dank.
Ihr habt mir sehr geholfen.
Viele Grüße
Tortom