日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

html循环查询的数据,SQL查询遍历数据方法一 [ 临时表 + While循环]

發(fā)布時(shí)間:2025/3/15 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html循环查询的数据,SQL查询遍历数据方法一 [ 临时表 + While循环] 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

以下以SQL Server 2000中的NorthWind數(shù)據(jù)庫中的Customers表為例,

用?臨時(shí)表 + While循環(huán)?的方法, 對(duì)Customers表中的CompanyName列進(jìn)行遍歷

create table?#temp

(

id?int?identity(1,1),

customer?nvarchar(50)

)

declare?@customer?nvarchar(50)

declare?@n????????int

declare?@rows?????int

select?@n=1

insert?#temp(customer)?select distinct?companyname?from?customers

select?@rows =?@@rowcount

while?@n <= @rows

begin

select?@customer = companyname

from?customers

where?companyname=(select customer?from?#temp?where?id = @n)

order by?companyname?desc

print(@customer)

select?@n = @n + 1

end

運(yùn)行后, 輸出結(jié)果如下:

(所影響的行數(shù)為 91 行)

Alfreds Futterkiste

Ana Trujillo Emparedados y helados

Antonio Moreno Taquería

Around the Horn

Berglunds snabbk?p

Blauer See Delikatessen

Blondesddsl père et fils

Bólido Comidas preparadas

Bon app‘

Bottom-Dollar Markets

B‘s Beverages

Cactus Comidas para llevar

Centro comercial Moctezuma

Chop-suey Chinese

Comércio Mineiro

Consolidated Holdings

Die Wandernde Kuh

Drachenblut Delikatessen

Du monde entier

Eastern Connection

Ernst Handel

Familia Arquibaldo

FISSA Fabrica Inter. Salchichas S.A.

Folies gourmandes

Folk och f? HB

France restauration

Franchi S.p.A.

Frankenversand

Furia Bacalhau e Frutos do Mar

Galería del gastrónomo

Godos Cocina Típica

Gourmet Lanchonetes

Great Lakes Food Market

GROSELLA-Restaurante

...... (以下略) ..................................

原文:http://www.cnblogs.com/shiyh/p/7171858.html

總結(jié)

以上是生活随笔為你收集整理的html循环查询的数据,SQL查询遍历数据方法一 [ 临时表 + While循环]的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。