Autor Beitrag
Zaubär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 99



BeitragVerfasst: So 27.10.02 11:44 
Hi,

wie kann ich in eine SQL-Abfrage eine Variable einbauen??

Ich habe eine Tabelle wo eine Spalte 'Katgorie' benannt ist. Nun möchte ich es so machen, dass man die Möglichkeit hat nur Produkte einer bestimmten Kategorie auszuwählen.
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: So 27.10.02 13:32 
Hallo Zaubär,

dazu benutzt du vor einem Bezeichner den Doppelpunkt:

ausblenden Quelltext
1:
SELECT * FROM Produkte where Kategorie= :kat					


Delphi erkennt, dass :kat ein Parameter ist und nimmt ihn in den Params - Array auf.

Du kannst jetzt schreiben:

ausblenden Quelltext
1:
2:
   qrySel.ParamByName('kat').Value := 'CD';
   qrySel.Open;


Beachte, dass der Parameter in ParamByName ohne Doppelpunkt erscheinen muss.

_________________
Live long and prosper
MrSpock \\//
Zaubär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 99



BeitragVerfasst: So 27.10.02 16:55 
Danke für die Hilfe, es hat funktioniert!

Weisst du zufälligerweise, wo ich mehr über SQL Befehel usw. finden kann, ich habe nämlich noch einige Probleme damit zu bewältigen und möchte nicht wegen jedem Detail ein Thema ins Forum setzen.
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 27.10.02 17:41 
Hier iauf diese Seite findest Du einiges :

home.t-online.de/hom...e/sqlhelp/index.html
Mahr
Hält's aus hier
Beiträge: 6



BeitragVerfasst: So 27.10.02 17:49 
Hi,

Also mir hat dieses Buch sehr geholfen

Dtenbanksprache für DOS Windows OS/2 und UNIX
SQL
von GREGOR KUHLMANN
FRIEDRICH MÜLLMERSTADT
ISBN 3-634-19289-5
rororo Computer

ist paar jahre her als ich es gekauft hab aber SQL ist ja auch nicht neu.
hat nix mit Delphi zutun aber dafür mehr mit SQL

cu Mahr