zoukankan      html  css  js  c++  java
  • 13、SQL基础整理(流程控制begin……end)

    流程控制

    begin ……end将一个语句块包含起来,中间可以写任何语句

    格式:

    begin--开始

        select *from student

    end--结束

     

    if

    declare @bianliang int

    set @bianliang = 10

    if @bianliang>10 print '你好'

    else print 'hello'

    if后面有多个语句,用begin  end作为分隔点

    declare @shuxue decimal(18,2)

    select @shuxue = MAX(shuxue) from fenshu

    declare @stuid int

    select @stuid = code from fenshu where shuxue = @shuxue

    ---select *from student where code = @stuid

    declare @sex varchar(20)

    select @sex = sex from student where code = @stuid

    if @sex = '男'

    print'这是男同学'

    else

    print'这是女同学'

     

    while

    declare @shuxue int

    set @shuxue = 75

    while @shuxue<80

    begin

        print'很好'

        set @shuxue = @shuxue+1

        if @shuxue = 79

        break

        print 'ok'

    end

    declare @shuxue int

    set @shuxue = 80

    while @shuxue<95

    begin

        print'很好'+cast(@shuxue as varchar(10))

        set @shuxue = @shuxue+1

        if @shuxue = 93

          break

        if @shuxue>85 and @shuxue<90

          begin

            continue

          end

        print 'ok'

    end

     

  • 相关阅读:
    定位及CSS常见属性
    浮动及清浮动的方法
    C语言II博客作业04
    C语言II—作业03
    C语言II—作业02
    C语言II博客作业01
    期末总结
    C语言I博客作业09
    C语言I博客作业08
    C语言I博客作业07
  • 原文地址:https://www.cnblogs.com/wleaves/p/4165085.html
Copyright © 2011-2022 走看看