sql三表查询
@邢爽2882:SQL 三表联查 -
敖凭17155965090…… select t.*,t1.hsdwmc , from a t join b t1 on t1.hsdwmc =t.thsdwmc join c t2 on t.fzmc = t2.fzmc 我上面这样写的需要所有表都有关联才行,如果不是所有表有关联换下面这种写法 select t.*,t1.hsdwmc , t2.fzmc from a t left join b t1 on t1.hsdwmc =t.thsdwmc left join c t2 on t.fzmc = t2.fzmc
@邢爽2882:求三表联合查询的SQL查询语句 -
敖凭17155965090…… 车讯语句:select username,psw from (a1 left join a2 on a1.a1_id=a2.a1_id) left join a3 on a1.a1_id=a3.a1_id 这样写: SELECT S.SName AS 姓名, CS.CourseName AS 课程, C.Score AS 成绩 FROM Students AS S INNER JOIN Score AS C ...
@邢爽2882:如何用一条SQL语句查询3个表中的内容? -
敖凭17155965090…… 前提是表的结构应该是一样的或者处理成一样的~~~~ 表A, aid, aname, atext 表B, bid, bname, btext 表C, cid, cname, ctext SELECT * FROM ( SELECT aid AS id, aname AS name, atext AS [text] FROM A UNION SELECT bid AS id, bname AS ...
@邢爽2882:3个表的SQL查询 -
敖凭17155965090…… select * from t1 where t_id not in (select user_id from t3 where lesson_id=(select t_id from t2 where 课程名='课程名')) 5个5个的显示出是不是就显示5个 select top 5 * from t1 where t_id not in (select user_id from t3 where lesson_id=(select t_id from t2 where 课程名='课程名'))
@邢爽2882:sql 三表连接查询 -
敖凭17155965090…… select student.stuno(学号),stuname(姓名),book.bookno(书号),count(amount),sum(price)as 应付 FROM student,book,bookorder where student.stuno=bookorder.stuno,book.bookno=bookorder.bookno group by stuno(学号) go
@邢爽2882:怎么用一句sql查询三个表并输出三个表的内容 -
敖凭17155965090…… select table1.id,table1.title,table1.content ,table1.s_time from table1 union select table2.id , table2.title_a , table2.content ,table2.time from table2 union select table3.id , table3.title , table3.content ,table3.time from table3 order by s_time 肯定正确啦^_^
@邢爽2882:求三表联合查询的SQL查询语句
敖凭17155965090…… select a.id,a.name,b.name,c.name,a.table2_id,a.table3_id,c.table2_id from table1 a,table2 b,table3 c where a.table2_id=b.id and a.table3_id=c.id and b.id=c.table2_id order by a.id; 以上语句在Oracle11g r2上测试通过,同样可以用于其他数据库,如有疑问请留言
@邢爽2882:SQL 三表查询
敖凭17155965090…… selecte 学生表.姓名,学生表.性别,学校表.学校名称 from 学生表,教师表,学校表感觉你教师表用都没用到为什么要教师表也?
@邢爽2882:sql 三表联合查询 -
敖凭17155965090…… select a.incode,a.inname,count(c.stzt) as stzt from industry_infor as a left jion workType_infor as b on a.incode=b.incode left jion exam_lltk_infor as c on b.workTypeCode = c.workTypeCode group by a.incode,a.inname
@邢爽2882:SQL 三表联合查询,查询一个表的和
敖凭17155965090…… 每个分类的答题记录的和 (使用的是子查询,当然也可以用联接查询),正确数记录的和你zhidao应该知道怎么弄了吧 select sum(RID) from 题目答题情况表 where TID in ( select TID from 题目表 where DID in (select DID from 分类表 group by Dname) )
敖凭17155965090…… select t.*,t1.hsdwmc , from a t join b t1 on t1.hsdwmc =t.thsdwmc join c t2 on t.fzmc = t2.fzmc 我上面这样写的需要所有表都有关联才行,如果不是所有表有关联换下面这种写法 select t.*,t1.hsdwmc , t2.fzmc from a t left join b t1 on t1.hsdwmc =t.thsdwmc left join c t2 on t.fzmc = t2.fzmc
@邢爽2882:求三表联合查询的SQL查询语句 -
敖凭17155965090…… 车讯语句:select username,psw from (a1 left join a2 on a1.a1_id=a2.a1_id) left join a3 on a1.a1_id=a3.a1_id 这样写: SELECT S.SName AS 姓名, CS.CourseName AS 课程, C.Score AS 成绩 FROM Students AS S INNER JOIN Score AS C ...
@邢爽2882:如何用一条SQL语句查询3个表中的内容? -
敖凭17155965090…… 前提是表的结构应该是一样的或者处理成一样的~~~~ 表A, aid, aname, atext 表B, bid, bname, btext 表C, cid, cname, ctext SELECT * FROM ( SELECT aid AS id, aname AS name, atext AS [text] FROM A UNION SELECT bid AS id, bname AS ...
@邢爽2882:3个表的SQL查询 -
敖凭17155965090…… select * from t1 where t_id not in (select user_id from t3 where lesson_id=(select t_id from t2 where 课程名='课程名')) 5个5个的显示出是不是就显示5个 select top 5 * from t1 where t_id not in (select user_id from t3 where lesson_id=(select t_id from t2 where 课程名='课程名'))
@邢爽2882:sql 三表连接查询 -
敖凭17155965090…… select student.stuno(学号),stuname(姓名),book.bookno(书号),count(amount),sum(price)as 应付 FROM student,book,bookorder where student.stuno=bookorder.stuno,book.bookno=bookorder.bookno group by stuno(学号) go
@邢爽2882:怎么用一句sql查询三个表并输出三个表的内容 -
敖凭17155965090…… select table1.id,table1.title,table1.content ,table1.s_time from table1 union select table2.id , table2.title_a , table2.content ,table2.time from table2 union select table3.id , table3.title , table3.content ,table3.time from table3 order by s_time 肯定正确啦^_^
@邢爽2882:求三表联合查询的SQL查询语句
敖凭17155965090…… select a.id,a.name,b.name,c.name,a.table2_id,a.table3_id,c.table2_id from table1 a,table2 b,table3 c where a.table2_id=b.id and a.table3_id=c.id and b.id=c.table2_id order by a.id; 以上语句在Oracle11g r2上测试通过,同样可以用于其他数据库,如有疑问请留言
@邢爽2882:SQL 三表查询
敖凭17155965090…… selecte 学生表.姓名,学生表.性别,学校表.学校名称 from 学生表,教师表,学校表感觉你教师表用都没用到为什么要教师表也?
@邢爽2882:sql 三表联合查询 -
敖凭17155965090…… select a.incode,a.inname,count(c.stzt) as stzt from industry_infor as a left jion workType_infor as b on a.incode=b.incode left jion exam_lltk_infor as c on b.workTypeCode = c.workTypeCode group by a.incode,a.inname
@邢爽2882:SQL 三表联合查询,查询一个表的和
敖凭17155965090…… 每个分类的答题记录的和 (使用的是子查询,当然也可以用联接查询),正确数记录的和你zhidao应该知道怎么弄了吧 select sum(RID) from 题目答题情况表 where TID in ( select TID from 题目表 where DID in (select DID from 分类表 group by Dname) )