正经来说,第三次来北京面试了,过去一个月经历了过山车般的起伏,最终还是决定重新找工作。10天之内面试了七八家公司,总体不够满意,掌握的知识还是不够系统,Java、PHP、mysql、数据结构都只是略懂一点。面试过程中遇到的经典面试题,分享给大家,欢迎来纠正。
mysql多表查询
已知学生表(student(id,name)),课表(class(id,name)),选课表(sc(studentid,classid)),请用多种方式查询出选了数学这门课的所有学生姓名(两种以上,并说明哪种效率最高)
- 使用in查询
1 | Select student.name from student where id in (select studentid from sc where classid in (select id from class where name='数学')); |
- 使用exists查询
1 | select student.name from student where exists (select studentid from sc where exists (select class.id from class where class.name = ‘数学’)); |
- 自然连接查询
1 | select student.name from student,class,sc where sc.studentid = student.id and sc.classid = class.id and class.name = ‘数学’; |
session状态保持
session机制,如果浏览器禁用cookie,怎么使用session保持状态?(用户禁止cookie后,如何继续使用session)
实现sessionId的跟踪,可以使用URL重写来实现Servlet 容器可以重写客户请求的 URL,把 Session ID 添加到 URL 信息中。 不能够直接写这个组件的地址,而应该使用服务器生成的这个地址,调用
1 | response.encodeURL("some") |
More info: PHP session状态保持