MySql连接查询

1、查询学生表中的学生名称以及成绩表中的学生成绩

select s.stuname,c.stuscore from students s INNER JOIN score c ON s.stuid=c.stuid;

  

2、根据性别分组并且查询分组中的内容

select GROUP_CONCAT(username),group_concat(sex),count(*) as '数量' from user1 group by sex;

3、外键级联删除与更新

FOREIG KEY(depId) REFERENCES departement(id)  ON DELETE CASCADE ON UPDATE CASCADE;

原文地址:https://www.cnblogs.com/javallh/p/9211327.html