范文无忧网面试笔试面试回答

数据库多表查询问题

01月25日 编辑 fanwen51.com

[SQL数据库试题求解]------------------------------------------------------ create table students(st_id varchar(20),st_name varchar(50),sex varchar(10)) insert into students(st_id,s...+阅读

select t1.name,t1.time,t2.score as englishscore,t3.score as chinesescore,t4.score as mathscorefrom(select a.studentid,a.name,b.timefromstudent a,(select time from english unionselect time from chinese unionselect time from math) b) t1left join english t2 on t1.studentid =t2.studentid and t1.time=t2.timeleft join chinese t3 on t1.studentid =t3.studentid and t1.time=t3.timeleft join math t4 on t1.studentid =t4.studentid and t1.time=t4.time (select a.studentid,a.name,b.timefromstudent a,(select time from english unionselect time from chinese unionselect time from math) b) t1这部分主要是通过笛卡尔积构造一个含有姓名和所有日期的一个列表,然后通过左连接去和其他三个表进行匹配,有的日期没有的,分数为空,如果你想显示0,不知道你用的什么数据库 sqlserver可以通过isnull函数,oracle可以通过nvl函数...

延伸阅读:

再问几道数据库的基本题目9、C.数据库中不应该存在任何冗余 解释:数据库恢复的基本原理用一个词概括就是:冗余。数据库中任何一部分被破坏的或不正确的数据可以根据存储在系统别处的冗余数据来重建。 1...

大学数据库试题大神帮忙解答。1. select 课程名 from 课程 where 学分>3 2. select 姓名 from 学生 where 学号 not in (select 学号 from 选修, where 课程号 = 'C2' ) 3. update 选修 set 成绩 = 5 wher...

SQL数据库题目解答 2.select sno,sname,major from student where major in(select cno from course where) 3.没有见到有选课表 4.select cname from course where cno not in(select distin...

SQL SERVER2005数据库考试题急create table T1 ( c1 VARCHAR2(6) not null, c2 VARCHAR2(6) not null, c3 VARCHAR2(6) not null, c4 VARCHAR2(6) not null, c5 VARCHAR2(6) not null) add constraint T1...

关于数据库SQL的一些简单题1.select 班级名称,班级代码 from 班级表 where 系部代码 in (02,03) 2.查询学生表中姓李的学生的学号、姓名、年龄 3.查询读者表姓名出现红字的读者 4.查询图书编号为10111...

数据库多表查询这4个题都怎么做呀1 select a.s# from (select s#,score from sc where c#='001') a inner join (select s#,score from sc where c#='002') b on a.s#=b.s# and a.score>b.score 2 select st...

数据库SQL查询语句面试题5.1 select a.username,b.deptname from users a,dept b where a.dept_id=b.id; 5.2 update users set dept_id='9' where dept_id='2'; 5.3 select a.deptname,b.count_id...

java面试题关于数据库的建表和查询1. USER表 ID,USER_NAME,GENDER,HOBBY,EDUCATION MERCHANT表 ID,NAME,SHOP,SEQ_NUM,PERSON,TEL LOGIN表 ID,NAME,PASSWORD,MOBILE 登陆表的id于会员表和商户表的id关联。 2....

数据库面试题1select a.产品名, isnull(b1.产品数量,0) as 仓库id_1, isnull(b2.产品数量,0) as 仓库id_2, isnull(b3.产品数量,0) as 仓库id_3, isnull(b4.产品数量,0) as 仓库id_4 from (sel...

推荐阅读
图文推荐
栏目列表