You are here

Neuen Kommentar schreiben

INNER JOIN - normal table join

Syntax

    WHERE a.Field1 = b.Field2
    before SQL92 (implicit declaration of table joins)

    FROM Table1 [Alias1] INNER JOIN Table2 [Alias2] ON {Table1|Alias1}.TableKey = {Table2|Alias2}.TableKey
    SQL92 (explicit declaration of table joins)

Description

    The inner or equal join is the "normal" way for joining two tables: the records of two tables are joined, when the join expression build upon the fields from both tables evaluates as true.

    Example:

-- before SQL 92
SELECT a.vnum, a.vname, b.knum, b.kname
FROM tverkauf a, tkunden b
WHERE a.vnum = b.vnum
ORDER BY vnum;

-- SQL 92
SELECT a.vnum, a.vname, b.knum, b.kname
FROM tverkauf a INNER JOIN tkunden b ON a.vnum=b.vnum
ORDER BY vnum;

Result:

vnum vname   knum kname
1    Mueller 1    Lehmann
1    Mueller 2    Schmidt
1    Mueller 3    Schumacher
2    Meyer   4    Schroeder
2    Meyer   5    Stoiber
3    Schulz  6    Lohmann
3    Schulz  7    Krupp
3    Schulz  8    Stradivari
3    Schulz  9    Schumacher
Categories: