本文介绍了更新查询两个表.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想通过考虑两个表来编写更新查询.就我而言,我想通过考虑某人的电子邮件ID来更改其密码.表示personPassword是人员表中的一个字段. personEmail是另一个表中的另一个字段.我的查询是:

Hi,

I want to write a update query by considering two table. In my case i want to change the password of a particular person by considering his email id. Means personPassword is one field in person table. And personEmail is another field in another table. My query is :

UPDATE Person
SET personPassword = @NewOrganizerPassword
Where personEmailID = @PersonEmailID



这两个表是:

1)人员:

PersonID
PersonPassword

2) Person_Email:

PersonID
人员电子邮件

如何编写用于更新个人密码的更新查询.

在此先感谢......



The two tables are :

1) Person :

PersonID
PersonPassword

2) Person_Email :

PersonID
PersonEmail

How to write the update query for updating the person password.

Thanks in advance......

推荐答案

UPDATE Person
SET Password = @Password
FROM Person p
INNER JOIN Person_Mail
ON p.Personid = Person_Mail.Personid
WHERE PersonMailID = @PersonMailID



看看类似的线程:
使用联接的SQL更新查询 [ ^ ]

以及在SQL UPDATE语句中使用SQL JOIN [ ^ ]



Have a look on similar thread:
SQL update query using joins[^]

And an article on Using A SQL JOIN In A SQL UPDATE Statement [^]


UPDATE Person
SET personPassword = @NewOrganizerPassword
Where PersonID =(select  PersonID from Person_Email  where personEmailID=@personEmailID)


这篇关于更新查询两个表.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 22:57