码迷,mamicode.com
首页 > 数据库 > 详细

SQL数据库的增删改查

时间:2015-06-02 12:58:27      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

例子:一个名为person的表,字段分别有name, age ,city,school,card,id

  注意:sql是对大小写不敏感

1.select : select name from person 查询出person表的所有name字段

     select * from person 查询person表的所有数据

     select distinct name from person 查询person表的所有数据,但是和上麦年不一样的是查询出的name是不会重复的

     select * from person where name=‘lisi‘查询名字是lisi的人。注意:条件查询的条件值要用单引号,但是如果是数值就不要使用引号

     select * from person where name="ll" and age=21

     select * fron person where ( name="dd" or age=34) and city=‘cn‘

  order by 用于对制定的列对结果进行排序

     select name,age from person order by name desc;查询结果按逆排序 asc按顺排序

2.insert :insert into person (name, age)values ("",20)

3.update:update person set name="ws",age=10 where age=21;

4.delete: delete from person where name=""

5.like :select name from person where name like ‘%h‘ 查找以h结尾的名字 ‘g%‘以g开头的名字 ‘%k%‘包含k的名字

   

 

SQL数据库的增删改查

标签:

原文地址:http://www.cnblogs.com/mylanlan-802888/p/4545785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!