sql 双表查询 急~~~~~~~~~~~在线等呀

来源:百度知道 编辑:UC知道 时间:2024/06/05 11:24:00
两个表
t1表 听课记录
id std_num course_date course_time std_name std_tel
111 1172 2009-1-1 1 张三 130********
112 1173 2009-1-2 2 李四 132********

t2表 购买记录
id std_num pro_date pro_detail std_tel std_name
101 1172 2009-8-12 产品名 130******** 张三

如何通过sql语句查询到张三这条记录
也就是得到以下结果
id course_date course_time pro_date pro_detail std_name std_tel
101 2009-1-1 1 2009-8-12 产品名 张三 130****
怎么能查到 李四 这条记录呢
也就是把两个表共同有的记录删掉

selecet * from 听课记录,购买记录 where 购买记录.std_name=听课记录.std_name

select id,Course_date,Course_time,pro_date,ti.std_name
where t1 left join t2 on t1.stu_name = t2.stu_name

select t2.id ,t1.course_date ,t1.course_time ,t2.pro_date ,t2. pro_detail ,t1.std_name ,t1.std_tel from t1,t2 where t1.std_num = t2.std_num