Mysqlマルチテーブルクエリ

967 ワード

mysql version: 5.7.*
データ#データ#
students
id
name
1001
tom
1002
jack
1003
jason
results
student_id
score
score_name
1001
60
Math
1002
70
History
1005
80
History
内部リンク
select * from student as s join results as r on s.id=r.student_id where r.score>60;
select * from 1 join 2 on 1.id= 2.id where
左リンク
left join左のテーブルのデータはすべてクエリーされ、右のテーブルの条件に合致するクエリーが出ます
select * from student as s left join retults as r on s.id=r.student_id where r.score>60
select * from 1 right join 2 on 1.id= 2.id where
右リンク
rigit join右のテーブルのデータはすべてクエリーされ、左のテーブルの条件に合致するクエリーが出ます
select * from student as s right join retults as r on s.id=r.student_id where r.score>60
select * from 1 left join 2 on 1.id= 2.id where