表内容的增删改查

crud  对表的增删改查
增 insert into
1.完全插入:例如:insert into 表名 values( 108401,' 小甜甜 ', 20,1,' 1245678999 ');
2.选择插入:例如:insert into 表名(userid,name,age) values( 10000,' 花花 ',19);
3.多行插入:例如:insert into 表名(userid,name) values(19999,' 葡萄 '),(18888,‘ 辣椒 ’);
查看已经插入的数据 select * from 表名 (*表示所有);
修改 跟新 update
1.跟新单个字段(列)
update 表名 set name = '娜娜' , age = 19 where id = 12345;
2.跟新多行
update 表名 set name = ' 娜娜 ' ;
3.跟新多个字段(列)
update 表名 set name = ' 娜娜 ' age = 19 where id = 18888 ;
将一个表复制到另一个表中
insert into 新表 (列名,列名...) select 列名,列名... from 原表 ;
删除数据 delete
删除特定的一行:例如:delete from 表名 where id = 10010 ;
删除所有行:例如:delete from 表名 (不能轻易做);
查询
  查询所有 select * from 表名 ;
  查询某一个 select * from 表名 where id = 13333 ;
  查询年龄这个列 select age from 表名 where id = 19999;
使用限定的方式查找,不进入数据库就可以查询到表的信息
  select * from 数据库名.表名;
使用 distinct 去重,返回不重复的列的值
  select distinct age from 表名;insert into 表 (列名,列名...) select 列名,列名... from 表
数据库的查询 where(过滤)
  查询一行 select * from 表名 where age = 6 ;
where 条件查询和运算符 
  = 等于 select * from 表名 where age = 6 ;
<> 不等于, != 不等于,
  < 小于, <= 小于等于, > 大于, >= 大于等于,
  between ... and 在两者之间(包含边界值);
例如:select name ,age from 表名 where age between 5 and 30 ;
  is null 判断某一列的数据,如果包含null ,则返回记录;
  例如:select * from 表名 where phone is null ;
and 链接查询条件,查询的数据要全部满足
  例如:select name from 表名 where userid>=18004 and age>99;
or 链接查询条件,查询的数据只要满足其中一个即可
  例如:select name from 表名 where userid>=18004 or age>90;
in 操作符 (相当于 or ) in (条件1,条件2,条件3);
  例如:selete name(列)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我正在一点一点剔除那些细枝末节,将自己变得越发纯粹,同时也会忽而难以捉摸,因为我和你一样,对未来有着某种与生俱...
    木木木姝子xz阅读 335评论 5 2
  • 读了这本书以后,我更知道了一个道理:提高阅读能力的最好也是唯一的技巧就是多读书,而掌握这个能力的技巧则是要输出即必...
    珊珊我的宝贝阅读 493评论 2 2
  • Spring Boot是一个微服务的框架,他免去了我们在SSH和SSM中繁琐的xml配置,给我们一种清爽的感觉。 ...
    赵镇阅读 415评论 0 3
  • 文|北城三月 银盏村毗邻城乡结合部,老耿头每次进城回来,必经这段坑坑洼洼的路面。今年雪下得凶,深一脚浅一脚,才到农...
    悟三藏阅读 1,122评论 0 4
  • 写在2017.09.19 最近新工作稳定些(加班还是忙成狗),某些晚上11点后还是有点自己的时间写写博客,最近对J...
    alivs阅读 330评论 0 1