検索
ホームページJava&#&面接の質問Java で頻繁に聞かれる基本的な面接の質問—(9)

Java で頻繁に聞かれる基本的な面接の質問—(9)

Java バックエンド開発者の資格を取得するには、データベースの知識が不可欠であり、データベースに精通しているかどうかの試験は、その人が確実な基礎スキルを備えているかどうかの試験でもあります。

(より関連した面接の質問に関する推奨事項: Java 面接の質問と回答 )

特に若手開発者にとって、面接ではフレームワーク関連の知識は問われない場合がありますが、ここでは、日常の開発や面接の準備に役立つ、一般的な SQL ステートメントのいくつかをまとめています。

基本的なテーブル構造:

 student(sno,sname,sage,ssex)学生表        
 course(cno,cname,tno) 课程表        
 sc(sno,cno,score) 成绩表
 teacher(tno,tname) 教师表

101、コース 1 の成績がコース 2 の成績よりも高いすべての生徒の生徒数をクエリします。

select a.sno from
(select sno,score from sc where cno=1) a,
(select sno,score from sc where cno=2) b
where a.score>b.score and a.sno=b.sno

102、平均値をクエリします。 60 を超える成績

select a.sno as "学号", avg(a.score) as "平均成绩" 
from
(select sno,score from sc) a 
group by sno having avg(a.score)>60

103 を獲得した生徒の生徒番号と平均成績。生徒番号、名前、受講したコース数、および全生徒の合計成績を照会します

select a.sno as 学号, b.sname as 姓名,
count(a.cno) as 选课数, sum(a.score) as 总成绩
from sc a, student b
where a.sno = b.sno
group by a.sno, b.sname

または:

selectstudent.sno as 学号, student.sname as 姓名,
 count(sc.cno) as 选课数, sum(score) as 总成绩
from student left Outer join sc on student.sno = sc.sno
group by student.sno, sname

104、姓が「Zhang」である教師の数をクエリします。

selectcount(distinct(tname)) from teacher where tname like '张%‘

または:

select tname as "姓名", count(distinct(tname)) as "人数" 
from teacher 
where tname like'张%'
group by tname

105 、「Zhang San」で学習していない教師の数を問い合わせる 生徒番号と生徒の名前

select student.sno,student.sname from student
where sno not in (select distinct(sc.sno) from sc,course,teacher
where sc.cno=course.cno and teacher.tno=course.tno and teacher.tname='张三')

(推奨学習: java コース)

106、コース 1 とコース 2 の両方を学習した学生に問い合わせます 学生番号、名前

select sno, sname from student
where sno in (select sno from sc where sc.cno = 1)
and sno in (select sno from sc where sc.cno = 2)

または:

selectc.sno, c.sname from
(select sno from sc where sc.cno = 1) a,
(select sno from sc where sc.cno = 2) b,
student c
where a.sno = b.sno and a.sno = c.sno

または:

select student.sno,student.sname from student,sc where student.sno=sc.sno and sc.cno=1
and exists( select * from sc as sc_2 where sc_2.sno=sc.sno and sc_2.cno=2)

107、「Li Si」を学習した教師を確認してください すべてのコースの全生徒の生徒番号と名前は

select a.sno, a.sname from student a, sc b
where a.sno = b.sno and b.cno in
(select c.cno from course c, teacher d where c.tno = d.tno and d.tname = '李四')

または:

select a.sno, a.sname from student a, sc b,
(select c.cno from course c, teacher d where c.tno = d.tno and d.tname = '李四') e
where a.sno = b.sno and b.cno = e.cno

108 です。コース番号 1 の成績がコース番号 2 の成績より高いすべての生徒の生徒番号。、Name

select a.sno, a.sname from student a,
(select sno, score from sc where cno = 1) b,
(select sno, score from sc where cno = 2) c
where b.score > c.score and b.sno = c.sno and a.sno = b.sno

109、スコアが 60 点未満のすべての生徒の生徒 ID をクエリします。 name

select sno,sname from student
where sno not in (select distinct sno from sc where score > 60)

110、学生 ID 1 を持つ少なくとも 1 つのコースをクエリします。 同じコースを勉強しているクラスメートの学生番号と名前

select distinct a.sno, a.sname
from student a, sc b
where a.sno <> 1 and a.sno=b.sno and
b.cno in (select cno from sc where sno = 1)

または:

select s.sno,s.sname 
from student s,
(select sc.sno 
from sc
where sc.cno in (select sc1.cno from sc sc1 where sc1.sno=1)and sc.sno<>1
group by sc.sno)r1
where r1.sno=s.sno

関連する推奨事項: Java 入門チュートリアル

以上がJava で頻繁に聞かれる基本的な面接の質問—(9)の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事はcsdnで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

WebStorm Mac版

WebStorm Mac版

便利なJavaScript開発ツール