Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate » MS SQL  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 关于文章和目录更新的一条疑难SQL
shengbinfoot





发贴: 5
积分: 0
于 2006-10-25 11:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
有这么一条SQL

update Category
set topic_num=ct from Category,(
select count(tid) as ct,category_id as cid
from Topic
where userid=$userid$
group by category_id) as c
where category_id=cid and userid=$userid$

Category:目录表
Topic:文章表
目的是更新某userid所有自建目录中的文章记录数,包括更新为0条。
问题是,当userid的某个目录中没有文章时,则topic_num是不更新的。
不知哪位高人提示该如何修改此SQL语句,或是有更好的建议。




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923