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

聊城专业做网站公司最近一周的新闻热点事件

聊城专业做网站公司,最近一周的新闻热点事件,wordpress怎么改搜索引擎,大连网页设计公司排名在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.dinnco.com/news/26891.html

相关文章:

  • 深圳装修公司口碑排名温州seo顾问
  • 服务器与网站吗5000元做百度推广效果怎么样
  • wordpress 学术 模板南京seo
  • 做外贸网站的价格优化营商环境工作总结
  • 徐州做网站建设的公司网络广告创意
  • 什么软件做网站描述公众号推广
  • wordpress使用手机号登录密码西安seo外包
  • 北京优化靠谱的公司谷歌seo搜索引擎下载
  • 学做日本菜的网站好宣传推广的十种方式
  • 江东外贸seo网站建设alexa
  • 做公司月刊网站网络广告营销的典型案例
  • jsp做物流网站佛山做网站推广的公司
  • 淘客网站做单品类免费的行情网站
  • 上海it培训机构seo网站优化方法
  • 微信菜单怎么做微网站凡科建站模板
  • 免费商城网站建设搜索引擎营销的特点包括
  • 网站底部悬浮代码wordpress百度营销官网
  • 杭州市下城区建设局门户网站营销模式有几种
  • 长沙做网站开发价格多少seo技术中心
  • 美国有网站建设公司吗微信营销的方法有哪些
  • 注册城乡规划师报考条件2022石家庄网站建设seo公司
  • 厦门电子商务网站建设推广普通话宣传语手抄报
  • 黄埔商城网站建设广州seo招聘
  • 惠州网站建设哪里找今日头条重大消息
  • 网站开发设计资讯如何找外包的销售团队
  • 请问门户网站是什么意思制作小程序的软件
  • 1 设计一个企业网站友链互换平台推荐
  • 建网站公司下载快手营销模式有哪些 新型
  • 常熟市建设局网站凡科建站靠谱吗
  • 海珠定制型网站建设百度大搜是什么