当前位置: 首页 > news >正文

一个商城网站开发要多少时间辽宁省建设工程信息网入辽打印

一个商城网站开发要多少时间,辽宁省建设工程信息网入辽打印,建筑人才网评职称,怎么查询企业信息在sql语句中,如果要实现诸如for循环一样的功能就会用到游标,但游标一定要慎用,因为使用游标对数据库性能有关很大的影响。 一、游标的一般格式: DECLARE 游标名称 CURSOR FOR SELECT 字段1,字段2,字段3,... FROM 表名 WHERE ...…

在sql语句中,如果要实现诸如for循环一样的功能就会用到游标,但游标一定要慎用,因为使用游标对数据库性能有关很大的影响。

一、游标的一般格式:

DECLARE 游标名称 CURSOR FOR SELECT 字段1,字段2,字段3,... FROM 表名 WHERE ...
OPEN 游标名称
FETCH NEXT FROM 游标名称 INTO 变量名1,变量名2,变量名3,...
WHILE @@FETCH_STATUS=0BEGINSQL语句执行过程... ...FETCH NEXT FROM 游标名称 INTO 变量名1,变量名2,变量名3,...END
CLOSE 游标名称
DEALLOCATE 游标名称 (释放游标)

二、具体实例:

declare @id int
declare @name varchar(50)
declare cursor1 cursor for         --定义游标cursor1
select * from table1               --使用游标的对象(跟据需要填入select文)
open cursor1                       --打开游标
fetch next from cursor1 into @id,@name  --将游标向下移行,获取的数据放入之前定义的变量@id,@name中
while @@fetch_status=0           --判断是否成功获取数据
beginupdate table1 set name=name+'1'where id=@id                           --进行相应处理(跟据需要填入SQL文)fetch next from cursor1 into @id,@name  --将游标向下移行
end
close cursor1                   --关闭游标
deallocate cursor1             --释放游标

功能说明:以select * from table1 的查询结果为基本表,即要循环的表,在循环到table1的每一行时执行name=name+’1’的更新操作。

三、游标嵌套
从表SupplyInfo中查询出标签关键词Keywords(如‘安全柜,工作台,BIOBASE,,’),然后根据’,’进行分割,分割出的单个关键词插入表LB_article_tags,并将SupplyInfo与LB_article_tags的关联关系插入表 lb_article_tags_relation,实现语句如下:

create proc aa_test
as
declare @id int,@tags varchar(50),@add_time datetime
declare cursor1 cursor for
select top(10) SupplyID,Keywords,AddDate from SupplyInfo order by supplyid desc
open cursor1
fetch next from cursor1 into @id,@tags,@add_time
while @@fetch_status=0
beginif (@tags is not null) and (@tags!='')begindeclare @value varchar(50)declare cursor2 cursor forselect [Value] from [dbo].[SplitString](@tags, ',', 1)open cursor2fetch next from cursor2 into @valuewhile @@fetch_status=0begindeclare @tag_id int,@co intselect @co=count(0) from LB_article_tags where title=@valueif @co=0begininsert into LB_article_tags(title,add_time) values(@value,@add_time)select @tag_id=@@IDENTITYinsert into lb_article_tags_relation(article_id, tag_id) values(@id, @tag_id)endelse if @co>0beginselect @tag_id=id from LB_article_tags where title=@valuedeclare @count intselect @count=count(0) from lb_article_tags_relation where article_id=@id and tag_id=@tag_idif @count=0insert into lb_article_tags_relation(article_id, tag_id) values(@id, @tag_id)endfetch next from cursor2 into @valueendclose cursor2deallocate cursor2 endfetch next from cursor1 into @id,@tags,@add_time
end
close cursor1
deallocate cursor1 
http://www.yayakq.cn/news/576986/

相关文章:

  • 郑州网站建设 app开发友情链接实例
  • 制作网站软件叫什么标书制作好学吗
  • 陕煤化建设集团网站矿建二公司软文大全800字
  • 自助建站帮助网免费查权重工具
  • 网站黏度安卓优化清理大师
  • 如何破解网站后台密码什么都能搜的浏览器
  • 外贸展示型网站建设公司新闻发布会的意义
  • 上海网站建设哪家服务好wordpress 左右图文排版
  • 国内网络科技网站建设在公司网站投简历该怎么做
  • 专业帮人做网站号码知乎 淘宝网站建设
  • c语言精品课程网站开发WordPress如何上传木马
  • 百度推广建设网站是干什么了罗伯特清崎说的网络营销是什么
  • 做淘宝代销哪个网站好企业邮箱账号注册
  • 沈阳网站 房小二建筑装修
  • 南京高端网站开发购物网站支付功能怎么做
  • 做境外域名网站产品vi设计哪家好
  • 做的网站上更改内容改怎么回事wordpress安装服务器
  • 网站建设制作要学什么最大的购物平台
  • 制作一个响应式网站开发工具微博网站认证 备案名称
  • 宝坻网站建设公司php访问网站
  • 惠州做网站公司哪家好网页制作软件破解版下载
  • 简约大方网站仿珠宝首饰网站开发
  • 百度建站多少钱网络营销十大经典案例
  • 网站服务器和网站备案吗低价自适应网站建设
  • 网站安装代码网站开发视频播放网站
  • 模仿ios系统的html网站威海外贸网站建设电话
  • 怎么给公司做微网站宝安区住房和建设局网站
  • 宝洁公司网站建设现状学徒网页设计师招聘
  • 快速网站优化技巧wordpress一定是主页吗
  • 上海动易 网站网站域名注册