1-- MySQL
2-- t1 = table1
3-- dt2 = column of table
4SELECT t1.dt2, t2.dt4, t2.dt5, t2.dt3 #get dt3 data from table2
5FROM table1 t1, table2 t2 -- Doesn't need to have t1, or t2
6WHERE t1.dt2 = 'asd' AND t2.dt4 = 'qax' AND t2.dt5 = 456
7
1CREATE VIEW V AS (
2
3 SELECT i.country,i.year,p.pop,f.food,i.income FROM
4 INCOME i
5 LEFT JOIN
6 POP p
7 ON
8 i.country=p.country
9 LEFT JOIN
10 Food f
11 ON
12 i.country=f.country
13 WHERE
14 i.year=p.year
15 AND
16 i.year=f.year
17);
1SELECT t1.dt2, t2.dt4, t2.dt5, t2.dt3 #get dt3 data from table2
2FROM table1 t1, table2 t2 -- Doesn't need to have t1, or t2
3WHERE t1.dt2 = 'asd' AND t2.dt4 = 'qax' AND t2.dt5 = 456