常用的SQL语句

来源:互联网 发布:万网云新建数据库 编辑:程序博客网 时间:2024/06/07 00:28

插入单行

insert [into] <表名> (列名) values (列值)
例:insert into Strdents (姓名,性别,出生日期) values ('陈乐','男','1980/6/15')

删除<满足条件的>行

delete from <表名> [where <删除条件>]
例:delete fromStrdents where name='陈乐'(删除表Strdents中列值为陈乐的行)

3 改

update <表名> set <列名=更新值> [where <更新条件>]
例:updateStrdents set性别=‘男’ where 姓名='陈乐'

精确(条件)查询

select <列名> from <表名> [where <查询条件表达试>] [order by <排序的列名>[asc或desc]]

select * from a
说明:查询a表中所有行和列

select * from a where f=5
说明:查询表a中f=5的所有行

select name from a where chengji>=60 order by desc
说明:查询a表中chengji大于等于60的所有行,并按降序显示name列;默认为ASC升序

使用like进行模糊查询

注意:like运算副只用于字符串,所以仅与char和varchar数据类型联合使用
例:select * from a where name like '赵%'
说明:查询显示表a中,name字段第一个字为赵的记录

0 0
原创粉丝点击