📄 subject_61693.htm
字号:
<p>
序号:61693 发表者:chugongzi 发表日期:2003-11-21 10:38:29
<br>主题:请教
<br>内容:我现在刚开始学习sql,请问在update时可以使用group by having这种语句么?如果不能使用那么下面这个问题有什么好方法解决么?<BR><BR>问题1:如果当前记录的part_no,bu_code两个字段有多条记录相等(换句话说就是按part_no,bu_code两个字段分类,记录数>1),则更新send_4a = null ,send_date_4a = sysdate1。<BR><BR>问题2:在表A和表B中要查询这样一种数据:(A.CUSTOMER_ID = B.CUSTOMER_ID AND A.ITEM = B.ITEM ) OR (A.ITEM不存在B中)第二个条件要怎么写。<BR><BR>小弟很着急,恳求各位大侠刊载江湖告急分上,使以援手。在下感激不尽
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:小乔 回复日期:2003-11-22 09:08:06
<br>内容:对于问题1<BR>能不能使用我不知道但你可以这样做啊<BR>declare @num int<BR>select part_no,bu_code,@num=count(*) from tablename<BR>group by part_no,bu_code having ......<BR>if @num>1<BR>update tablename<BR>set send_4a=null<BR>set send_date_4a=sysdate1<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:小乔 回复日期:2003-11-22 09:11:18
<br>内容:问题2<BR>A.CUSTOMER_ID = B.CUSTOMER_ID AND A.ITEM = B.ITEM ) OR (A.ITEM not in(select item from b))<BR><BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:邓瑞涛 回复日期:2003-11-23 02:39:16
<br>内容:回复第1 个问题:<BR>update tablename<BR>set send_4a=null<BR>set send_date_4a=sysdate1<BR>where part_no in <BR>(select part_no from tablename group by part_no,bu_code having count(*)>1)
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -