MySQL中如何查询数据(上)

MySQL查询数据


一、MySQL的列选择


select * | 投影列 from 表名;


查询 departments 表中的所有数据;

Select * from departments;

二、MySQL的行选择


*Select |投影列 from 表名 where 选择条件;


查询 departments 表中部门 ID 为 4 的部门名称与工作地点 ID。

Select department_name,location_id from departments where department_id = 4;

三、Select 语句中的算术表达式


在这里插入图片描述

+:加法运算;

-:减法运算;

*:乘法运算;

/:除法运算;

%:取余运算,返回余数;

一、修改 employees 表添加 salary。

Alter table employees add salary float(8,2);

二、向employees表中添加数据;

Insert into employees values(1,”miwa”,null,null,1500);
Insert into employees values(2,”hibi”,null,null,1800);

三、查询雇员的年薪。

Select last_name,salary*12 from employees;

四、计算 employees 表中的员工全年薪水加 100 以后的薪水是多少?

Select last_name , salary*12+100 from employees;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值