sql
叫我莫言鸭
这个作者很懒,什么都没留下…
展开
-
删除数据库和表
if DB_ID('asd')is not null drop database asd print '成功' go create database asd go use student2012 go if object_id('asd','u')is not null drop table asd print '成功' go create table asd ( sname int ) go...原创 2020-01-07 17:30:31 · 216 阅读 · 1 评论 -
sql字符串查询
查询特定格式的字符 例如 查询姓李的学生 select * from student where sname like '李%' 如果是查询姓李或李两个字或三个字的名称 select * from student where left(sname,1) in ('李','张') and len(sname)<=3 and len(sname)>=2 如果查询姓李的两个字的名称 s...原创 2020-01-07 16:41:29 · 1094 阅读 · 0 评论 -
查询各个班级男生女生个数(case)
这里的case,是在搜索时进行的,遍历时逐条判定, use student2012 select 班级表.班名,sum(case 性别 when '男' then 1 else 0 end ) 男生人数, sum(case 性别 when '女' then 1 else 0 end )...原创 2020-01-07 16:17:44 · 4679 阅读 · 0 评论 -
SQL数据库登录失败
https://blog.csdn.net/Oh___/article/details/89684702转载 2019-12-18 16:00:59 · 767 阅读 · 0 评论 -
case给变量赋值
declare @d int ,@s char(20) set @d=3 set @s= case when @d=1 then 'is adasdas' when @d=2 then 'is 2a' else 'aaaaa'原创 2019-10-22 15:28:16 · 1259 阅读 · 0 评论