MySQL

  • 数据库操作语言DML(DATABASE Manipulation LANGUAGE)
  1. Insert 
    Insert into 表名 (id,name,birthday) va7ues (1,’wyx’,’2003-07-01 09:15:23’);
    
    
    
    Select
    Select * from weiyuxuan where id<>3;
    
    Select countryside,count(id) from world.city group by countryside;
    
     select count(id),name,length from c  where name like '%c%'group by length;
    
    
    
    Select district,count(id) from world.city where countrycode=’chn’ group by district;
    
    select max(s_birth),s_sex from student group by s_sex;按照性别取年龄最小
    
     select * from student where s_sex='女' and s_birth = '1992-03-01';取女性生日在’1992-03-01’的人、
    
     select * from student where s_sex='女' and s_birth = (select max(s_birth) from student where  s_sex='女');女性年龄最小
    
     select * from student where s_sex='男'and s_birth=(select max(s_birth) from student where s_sex='女');男性中与女性年龄最小同岁
    
    select count(s_id),year(s_birth) from student group by year(s_birth);求生日在各年的有几个
    
     select count(s_id),year(s_birth) from student group by year(s_birth) having count(s_id)>3;结果之后再查询用having
    
    
    
    select * from course c left join score s on c.c_id=s.c_id;关联语句
    
     select s_score,s.c_id,c_name from course c left join score s on s.c_id=c.c_id where s.c_id is null or s_id is null;课程有但没成绩left join 以左边为准right join 以右边为准
    
    
    
    --多表关联 找各表关联列
    
    select * from student s
    
    left join score f on s.s_id=f.s_id
    
    left join course c on c.c_id=f.c_id
    
    left join teacher t on t.t_id=c.t_id;
    
    > select * from student s left join score f on s.s_id=f.s_id left join course c on c.c_id=f.c_id left join teacher t on t.t_id=c.t_id where c_name='语文';
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值