mysql基础知识
1.创建数据库
mysql> CREATE DATABASE IF NOT EXISTS homestead DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> CREATE DATABASE IF NOT EXISTS abc DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
2.连接查询
1.内连接(INNER JOIN)
等值连接
SELECT A.*, B.*
FROM student_info A inner join student_score B
ON A.student_id = B.student_id
非等值连接
SELECT A.*, B.*
FROM student_info A inner join student_score B
ON A.student_id > B.student_id
2.左外连接(LEFT OUTER JOIN)
SELECT A.*, B.*
FROM student_info A left join student_score B
ON A.student_id = B.student_id
3.右外连接(RIGHT OUTER JOIN)
SELECT A.*, B.*
FROM student_info A right join student_score B
ON A.student_id = B.student_id
网友评论