时间:2021-07-01 10:21:17 帮助过:2人阅读
--新增一条语句,并且立刻获取他的主键id(这个用的很多啊,比如餐厅管理)
insert into gb_data( username, body, ip) values (‘xiayu222‘,‘ewdfdf‘,‘172.1.1.0‘);select @@IDENTITY
--查询语句十分强大,几乎可以查任何东西
--查询SqlServer版本
select @@VERSION as 版本
--查询日期
select GETDATE()as 日期
下面我们来重点说说查询语句
--查询符合条件的记录
select *from gb_data where username=‘夏雨‘
--查询对表进行排序后的操作(order by)
select *from gb_data order by createdate,username
--order by语句一定要放在where语句后面(否则会报错 ---关键字 ‘where‘ 附近有语法错误。)
select *from gb_data where username=‘夏雨‘ order by createdate
--模糊查询用like关键字,_表示一个字符,%表示多个字符
select *from gb_data where username like ‘%雨%‘
select *from gb_data where username like ‘_雨%‘
注:NULL表示“不知道”,有NULL参与的运算结构一般都为NULL,查询数据是否为NULL,不能用=,!=,要用IS关键字
--查询某一个范围内的数据可以用IN关键字
select * from person where age in(18,19,20)
常用SQL语句的整理--SQL server 2008(查询一)
标签: