• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

mysql => INNER JOIN

laubi

New member
Hallo Ihr,

ich versuche einen INNER JOIN-SELECT auf Tabellen zu machen und erhalte immer einen Lesefehler, was mache ich falsch?

Tabellenaufbau:

tab1 =
Field Type Attributes Null Default
user varchar(100) No 0
tag int(2) No 0
nr int(1) No 0
ti int(1) No 0

tab2 =
Field Type Attributes Null Default
tag int(2) No 0
nr int(1) No 0
nis int(1) No 0

$tabelle1= "tab1";
$tabelle2= "tab2";

$result=MYSQL_QUERY( "SELECT tab1.user, tab1.tag, tab1.nr FROM $tabelle2 INNER JOIN $tabelle1 ON (tab2.nr = tab1.nr) " )
or die ( "<H3> Lesefehler! </H3>");

Vielen Dank fuer Eure Antwort!

MfG

Laubi
 
Hi,

probier's mal ohne Klammern:

$result=MYSQL_QUERY("SELECT tab1.user, tab1.tag, tab1.nr FROM $tabelle2 INNER JOIN $tabelle1 ON tab2.nr=tab1.nr" )
or die ( "<H3> Lesefehler! </H3>");


mfG Enrique..
 
Hmm,
ich wusste gar nicht, daß MySql den Inner Join Befehl kann... Ich meine Foreign key kann es ja auch nicht...

CU
MichiS
 
Hi there,

inner join wird auch erst ab version 3.23.16 unterstützt.
Ich hab auch mal unter foreign key nachgeschaut und folgendes hab ich gefunden:

The FOREIGN KEY syntax in MySQL exists only for compatibility with other SQL vendors' CREATE TABLE commands; it doesn't do anything. The FOREIGN KEY syntax without ON DELETE ... is mostly used for documentation purposes. Some ODBC applications may use this to produce automatic WHERE clauses, but this is usually easy to override. FOREIGN KEY is sometimes used as a constraint check, but this check is unnecessary in practice if rows are inserted into the tables in the right order. MySQL only supports these clauses because some applications require them to exist (regardless of whether or not they work!).

mfG Enrique
 
meine Version

Hallo Ihr,

ich habe eine MYSQL-Version von 3.22.32. Wenn ich Euch richtig verstanden habe, ist dort der INNER JOIN - Befehl nicht unterstuetzt, ist das richtig?

Wenn ja muss ich mir was anderes einfallen lassen!

MfG

Laubi
 
Loesung (ohne INNER JOIN)

Hallo Ihr,

ich habe die Anforderung jetzt ohne INNER JOIN realisiert, hier die Loesung:

$result=MYSQL_QUERY( "SELECT tab1.user, tab2.tag FROM $tabelle1, $tabelle2 WHERE tab2.nr=tab1.nr" )
or die ( "<H3> Lesefehler! </H3>");

Danke fuer Eure Mithilfe!

MfG

Laubi
 
Zurück
Oben