增删改查

增:insert into `table` (`id`,`name`,`sex`,`grade`) value('1','张三','男','三年级')

删:delete from `table` where `id` = '1'

改:update 'table' set `name` = '李四' where `id` = '1'

查:-- 查询全部数据

  select * from `student`

  -- 查询指定字段

  select `studentNo`, `studentName` from student

  -- 别名,给结果起一个名字  As 可以给字段起名字,也可以给表起别名

  select `studetNo` As 学号, `studentName` As 学生姓名 from student As t

  -- 函数  Concat(a, b)

  select Concat('姓名: ',studentName) As 新姓名 from student

  select * from `table` where `name` = '张三'  and `sex` = '女'

  --数据库的列(表达式)

  select version() --查询系统版本

  select 100*3-1 As 计算结果 -- 用来计算 (表达式)

  select @@auto_increment_increment -- 查询自增的步长 (变量)

 

  去重:distinct

  发现重复数据,去重:select distinct `studentNo` from result

  

  -- 学员考试成绩 + 1分查看

  select `studentNo`, `studentResult` +1 As '提分后' from result

 

  数据库中的表达式: 文本值,列,Null, 函数, 计算机表达式, 系统变量。。。

  select 表达式 from 表

posted @ 2022-08-30 23:08  做人要有梦想  阅读(238)  评论(0)    收藏  举报