2017-06-22 5 views
-2

Meine erste Tabelle t1 Spalten:mit Zustand in anderen Tabelle

t_id, c_id, town 

Mein 2. Tabelle t2 hat Spalten:

p_id, year_of_birth, t_id -- < is ref to t_id in 1st table 

Ich möchte so etwas wie dieses (Pseudo-Code) :

SELECT year_of_birth from 2st where 
(
(t_id from 2st) = t_id from 1st) AND (c_id from 1st) = 'text value' 
) 
; 

Wie würde das in SQL funktionieren?

Antwort

0

Verwenden einer Ebene INNER JOIN:

SELECT t2.year_of_birth 
FROM t1 
JOIN t2 USING (t_id) 
AND t1.c_id = 'text value'; 

Basics in the manual.

Verwandte Themen