久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 T-SQL 中具有多個(gè)條件的 while 循環(huán)

While loop with multiple conditions in T-SQL(在 T-SQL 中具有多個(gè)條件的 while 循環(huán))
本文介紹了在 T-SQL 中具有多個(gè)條件的 while 循環(huán)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

首先讓我說(shuō)我知道我知道這種循環(huán)很可怕,你不應(yīng)該在 Transact SQL 中使用它們.但是,出于某些目的(這些目的無(wú)關(guān)緊要,所以不要問(wèn)我你想做什么!?")你只需要這樣做.我不想,但我必須.

Let me start out by saying I know I KNOW that these kind of loops are horrible and you shouldn't use them in Transact SQL. But, for some purposes (those purposes being irrelevant so don't ask me "what're you trying to do!?") ya just have to. I don't want to, but I gotta.

無(wú)論如何.有沒(méi)有辦法讓 T-SQL 中的 while 循環(huán)在復(fù)雜的條件語(yǔ)句上終止?就像,在 C# 中,我只想說(shuō) while (i > -10 && i <10) ,因?yàn)槲蚁Mh(huán)在標(biāo)記值介于 -10 和 10 之間時(shí)終止,但我只是...可以不知道怎么做.

Anyway. Is there some way to have a while loop in T-SQL terminate on a complex conditional statement? like, in C# I'd just say while (i > -10 && i < 10) , because I want the loop to terminate when the sentinel value is between -10 and 10, but I just... can't figure out how to do it.

這可能非常簡(jiǎn)單……或者……不可能.請(qǐng)指教.

It's probably excruciatingly simple... or.. impossible. Please advise.

現(xiàn)在,我剛剛得到

WHILE @N <> 0
BEGIN
   --code and such here
END

推薦答案

你必須看WHILE語(yǔ)句的聲明:

You must look at declaration of WHILE statement:

WHILE Boolean_expression 
     { sql_statement | statement_block | BREAK | CONTINUE } 

首先,你可以像 Dan 所說(shuō)的那樣使用復(fù)雜的 Boolean_expression:

First of all you can use complex Boolean_expression as Dan said:

WHILE @N > -1 AND @N <10
BEGIN
END

如果您想為代碼添加更多靈活性,可以使用 IF 與 BREAK,類似這樣:

If you want to add more flexibility to you code you can use IF with BREAK, something like this:

WHILE @N > -1 AND @N <10
BEGIN

  -- code
  IF (SELECT MAX(ListPrice) FROM Production.Product) > $500
    BREAK
  END
  -- code

END

退出循環(huán)或使用 CONTINUE 跳過(guò)一個(gè)循環(huán).

to go out of cycle or use CONTINUE to skip one cycle.

這篇關(guān)于在 T-SQL 中具有多個(gè)條件的 while 循環(huán)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個(gè)子標(biāo)記轉(zhuǎn)換為具有多個(gè)分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個(gè)表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計(jì)算值創(chuàng)建計(jì)算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對(duì)?) - IT屋-程序員軟件開(kāi)發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(hào)(問(wèn)題和答案的組合))
主站蜘蛛池模板: 久久av影院 | 精品影院| 中文字幕视频一区二区 | 亚洲综合中文字幕在线观看 | 日韩在线观看中文字幕 | 日韩欧美在线观看视频网站 | 黄色片在线网站 | 一区二区在线不卡 | 久久黄网| 亚洲国产自产 | 天天爽综合网 | 这里精品 | 国产精品久久av | 久久久涩| 中文字幕高清一区 | 国产不卡一区 | 亚洲成人中文字幕 | 欧美日韩91 | 国产精品1区 | 久久久久久久一区 | 亚洲高清一区二区三区 | 亚洲一区二区电影网 | 在线不卡av| 能免费看的av | 国产精品九九九 | 成人在线精品视频 | 日韩一区二区福利视频 | 毛片av免费看 | 视频在线一区二区 | 国产一区二区三区四区 | 欧美精品一区二区在线观看 | a免费视频| aaa综合国产 | 日本黄色一级片视频 | wwwsihu| 色偷偷888欧美精品久久久 | 日韩激情在线 | 免费国产视频 | 亚洲精品黄色 | 午夜爱爱毛片xxxx视频免费看 | 欧美久久一级特黄毛片 |