USE pubs SELECT a.au_lname, a.au_fname, t.title FROM authors a INNER JOIN titleauthor ta ON a.au_id = ta.au_id JOIN titles t ON ta.title_id = t.title_id WHERE t.type = 'trad_cook' ORDER BY t.title ASC
select * from a inner join b on b.x=a.x inner join c on c.x=b.x
select * from a join b on a.id=b.id join c on a.id=c.id
select * from a inner join b on a.id=b.id inner join c on a.id=c.id
select b1, b2, b3 from table1 join table2 on a1=a2 join table3 on a1=a3 where a1 not null
假设a:主表,b,c是从表 字段: a_b_id 对应b_id; a_c_id对应c_idselect * from a left outer join b on a.a_b_id = b.b_id left outer join c on a.a_c_id = c.c_id这样,保证a表的所有记录都至少出现一次
select t1.age,t2.name,t3.tel from t1,t2,t3 where t1.id=t2.id and t2.id=t3.id
SELECT a.au_lname, a.au_fname, t.title
FROM authors a INNER JOIN titleauthor ta
ON a.au_id = ta.au_id JOIN titles t
ON ta.title_id = t.title_id
WHERE t.type = 'trad_cook'
ORDER BY t.title ASC
字段:
a_b_id 对应b_id;
a_c_id对应c_idselect * from a
left outer join b on a.a_b_id = b.b_id
left outer join c on a.a_c_id = c.c_id这样,保证a表的所有记录都至少出现一次
where t1.id=t2.id and t2.id=t3.id