Autor Beitrag
kde2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Mi 31.08.05 14:27 
Hi!

Ich bin neu was SQL angeht, daher bräuchte ich Hilfe.
Habe 3 Tabellen:
bisher ist der SQLString so:
ausblenden Quelltext
1:
select table3.Spalte2 from table3 where table3.Spalte1 in (select spalte2 from table2 where spalte1=13)					

es wird nach einem Wert in Tabelle3, Spalte2 gesucht
mit Hilfe von Spalte1. Dieser Wert(Tabelle3.Spalte1) wird aus Spalte2(Tabelle2) mit Schlüssel aus Spalte1(Tabelle2) rausgelesen.
Das Ergebnis bekommt eine TQuery.
Ich will aber dass in dieser Query nicht nur die Spalte2 aus Tabelle3 angezeigt wird sondern auch die Spalte1 aus Tabelle1.
habe mir dass so vorgestell:
ausblenden Quelltext
1:
select tabelle1.spalte1,table3.Spalte2 from tabelle1,table3 where table3.Spalte1 in (select spalte2 from table2 where spalte1=13)					

ist falsch ich weiß! Es kommt eine Meldung:
'More than one table but no JOINing defined'
anscheinend fehlen Joins. Weiß nicht was damit gemeint ist und hoffe auf Erklärung und Beispiele.


Gruß Konstantin
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mi 31.08.05 14:30 
Joins sind Verbindungen von 2 oder mehr Tabellen zu einer Abfrage.

Wie die Syntax genau ist, hängt von der verwendeten Datenbank ab. Bei allen Datenbanken sollte aber folgendes funktionieren:

ausblenden Delphi-Quelltext
1:
2:
3:
Select tab1.sp1, tab2.sp2 
  from tab1, tab2
 where tab1.sp3 = tab2.sp4


Anonsten einfach mal Suche bei Google JOIN

_________________
Bravery calls my name in the sound of the wind in the night...
kde2005 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Mi 31.08.05 14:50 
sorry, hilft mir nicht weiter.
als anhang habe ich eine kleine skizze was ich überhabt will.
das wichtigste was ich will ist wie ich wenn ich eine spalte mit sqlstrings bekomme und anzeige dann noch eine spalte aus tabelle1 anzeigen kann.
Einloggen, um Attachments anzusehen!
firus1983
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 170

Win98,XP,
D6 Entrpr
BeitragVerfasst: Mi 31.08.05 15:24 
such mal im netz nach dem ebook "sql in 21 tagen" das sollte zu finden sein...

da ist alles inkl. JOIN erklärt.

_________________
Veni Vidi Codi !
Ich kam, sah, und programmierte !
kde2005 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Do 01.09.05 07:57 
danke! habe es hinbekommen.
hier der SQL String den ich brauchte.

ausblenden Quelltext
1:
select table3.name,table2.id_satz,table3.ident from table3 JOIN table2 on table2.id_stamm=table3.ident  where table2.id_satz = 13