MySql知识体系总结(

MySql知识体系总结(SQL优化篇)_GooReey的博客-CSDN博客


1、建表语句
CREATE TABLE `student` (
`id` int(10) NOT NULL,
`name` varchar(20) NOT NULL,
`age` int(10) NOT NULL,
`sex` int(11) DEFAULT NULL,
`address` varchar(100) DEFAULT NULL,
`phone` varchar(100) DEFAULT NULL,
`create_time` timestamp NULL DEFAULT NULL,
`update_time` timestamp NULL DEFAULT NULL,
`deleted` int(11) DEFAULT NULL,
`teacher_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `teacher` (
`id` int(11) DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
`course` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2、左连接查询 
explain select s.name,t.name from student s left join teacher t on s.teacher_id = t.id where t.course = '数学'

Related Keywords

Vietnam , Republic Of , , Code Example , Introduction Guo , வியட்நாம் , குடியரசு ஆஃப் ,

© 2025 Vimarsana