请帮助使用复杂的更新语句逻辑 [英] Please Help With Complex Update Statement Logic
问题描述
嗨。
我有一个更新声明的问题。每次
我运行它,每一次行更新,而不仅仅是那些预期的。
所以,这就是我所拥有的。我用AND和OR
尝试了这个并且似乎都没有用。
i不知道为什么这是在逃避我,但我会感激帮助使用
解决方案。
谢谢。
UPDATE添加
SET add_s = 1
WHERE add.add_status = 0和add.add_email =''m*****@rice.edu''
或add_s in
(
SELECT a.add_s
FROM添加a,编辑e
WHERE a.email_address = e.email_address
和e.public_name =''教授''
)
尝试添加一些括号
UPDATE add
SET add_s = 1
WHERE(add.add_status = 0 and add.add_email =' 'mag ... @ rice.edu'')
或add_s in
(
SELECT a.add_s
FROM添加a,编辑e
WHERE a.email_address = e.email_address
和e.public_name =''教授''
)
感谢您的建议,
但结果仍然相同 - 全部行更新
到新值,而不仅仅是单个预期行。
其他想法?
pbd22写道:
感谢您的建议,
但是结果仍然相同 - 所有行都更新
到新值,而不仅仅是单一的预期行。
其他想法?
测试你的WHERE子句如下:
SELECT * FROM add
WHERE(add .add_status = 0和add.add_email =''mag ... @ rice.edu'')
或add_s in
(
SELECT a.add_s
FROM添加a,编辑e
WHERE a.email_address = e.email_address
和e.public_name =''教授''
)
-----------------------
Alex Kuznetsov
http:// sqlserver-tips .blogspot.com /
http:// sqlserver-puzzles。 blogspot.com/
hi.
I am having probelms with an update statement. every time
i run it, "every" row updates, not just the one(s) intended.
so, here is what i have. i have tried this with both AND and OR
and neither seem to work.
i dont know why this is elluding me, but i''d appreciate help with the
solution.
thanks.
UPDATE add
SET add_s = 1
WHERE add.add_status = 0 and add.add_email = ''m*****@rice.edu''
or add_s in
(
SELECT a.add_s
FROM add a, edit e
WHERE a.email_address = e.email_address
and e.public_name = ''professor''
)
Try adding some brackets
UPDATE add
SET add_s = 1
WHERE (add.add_status = 0 and add.add_email = ''mag...@rice.edu'' )
or add_s in
(
SELECT a.add_s
FROM add a, edit e
WHERE a.email_address = e.email_address
and e.public_name = ''professor''
)
thanks for the suggestion,
but the results are still the same - all the rows update
to the new value, not just the single, intended row.
other thoughts?
pbd22 wrote:thanks for the suggestion,
but the results are still the same - all the rows update
to the new value, not just the single, intended row.
other thoughts?Test your WHERE clause as follows:
SELECT * FROM add
WHERE (add.add_status = 0 and add.add_email = ''mag...@rice.edu'' )
or add_s in
(
SELECT a.add_s
FROM add a, edit e
WHERE a.email_address = e.email_address
and e.public_name = ''professor''
)
-----------------------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/
这篇关于请帮助使用复杂的更新语句逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!