Autor Beitrag
wunsiedler
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 506
Erhaltene Danke: 4

Win7

BeitragVerfasst: Mo 02.08.04 16:08 
also,

ich habe in einer Tabelle eine Spalte die Stichworte heist. In der werden Wörter in der Form "Wort1,Wort2,Wort3,..." abgelegt. Nun lass ich nach einem Stichwort suchen, z.B. 'Wort1'. Wie heist bitte der SQL-String, der mir dann den passenden Datensatz anzeigt?

select * from buecher where stichworte = wort1

funktioniert nicht und bricht mit einer Fehlemeldung ab (ungültiger Feldname wort1).
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mo 02.08.04 16:58 
WHERE feldname = 'wort'

Strings müssen in Hochkommata gepackt werden, sonst wärs ein Feld.

_________________
Ha! Es compiliert! Wir können ausliefern!
wunsiedler Threadstarter
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 506
Erhaltene Danke: 4

Win7

BeitragVerfasst: Mo 02.08.04 18:02 
Aber dann findet er es trotzdem nicht da ja "wort1,wort2,..." drinsteht. Steht nur Wort1 drin und ich suche danach, dann klappt es.
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mo 02.08.04 18:26 
INSTR ist bei SQL das, was POS unter Delphi ist, d.h. du kannst also die Position eines Substring ermitteln.

Versuch also WHERE INSTR(Feld1, 'Wort') > 0

Das ganze ist aber ungeprüft.

_________________
Gruß
Martin
wunsiedler Threadstarter
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 506
Erhaltene Danke: 4

Win7

BeitragVerfasst: Mo 02.08.04 18:31 
Habs gelöst mit

SELECT * FROM buecher WHERE stichworte LIKE "%wort1%"