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

Win7

BeitragVerfasst: Di 18.05.04 22:28 
Hallo,

erstelle in der Datenbankoberfläche eine Abfrage. Diese möchte ich über TTable und DataSource in ein DBGrid anzeigenlassen. Als Quelle im TTtable werden mir aber nur Tabellen angezeigt. Wie bekomm ich die da rein?

Danke im vorraus

---------------
Delphi 3 Prof
atarigold
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

WIN XP, Linux 2.4
D7, Delphi 2006 Prof
BeitragVerfasst: Mi 19.05.04 18:23 
Warum verwendest du nicht anstelle von TTable die Komponente TQuery ?? Diese ist für
das Ausführen von Abfragen aus Delphi vorgesehen.


Mit Ttable gibt es nur die Möglichkeit über Views:
Wenn deine Datenbank das erlaubt, kannst du eine Abfrage als View definieren, nach dem Muster: ´
CREATE VIEW <name> AS .....deine Abfrage

Views können wie normale Tabellen angesprochen werden.

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

Win7

BeitragVerfasst: Fr 21.05.04 13:25 
Müsste aber eine abfrage über 3 tabellen machen. ist das mir TQuery möglich?
atarigold
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

WIN XP, Linux 2.4
D7, Delphi 2006 Prof
BeitragVerfasst: Fr 21.05.04 14:23 
Eine Abfrage über 3 Tabellen ist kein Problem. Stichwort Join.

Hier auf die Schnelle der EQUI-JOIN:

SELECT m1.spaltex, m1.spaltexx, m2.spaltey, m2.spalteyy, m3.spaltez .... FROM tablex AS m1, tabley AS m2, tablez AS m3
WHERE
m1.spalte_gleich1=m2.spalte_gleich1 and
m1.spalte_gleich2=m3.spalte_gleich2 and

..... hier folgen dann deine weiteren Filterbedingungen


spaltex, usw. werden dann im DBGrid angezeigt. Wenn du alle aus der ersten Tabelle angezeigt haben möchtest, verwende einfach m1.*
hinter FROM die ausgewählten Tabellen,

anschließend die Spalten miteinander verknüpfen die in Beziehung zueinander stehen.

Je nach DBMWS ist der InnerJoin möglicherweise etwas schneller, aber wenn es keine Riesen-Tabellen sind, versuchs erstmal mit dem Equi-Join.


atarigold
wunsiedler Threadstarter
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 506
Erhaltene Danke: 4

Win7

BeitragVerfasst: Fr 21.05.04 14:35 
Ich werde es ausprobieren. Danke erst mal für die umfassende Antwort. :lol: