一次更新2个表 [英] Updating 2 Tables at once

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

问题描述

任何可以提供帮助的人的快速提问:


我有两张桌子:


tblUsers

- -------

用户ID

名称


tblPhones

---- -----

PhoneID

UserID

PhoneNumber


如果我正在收集一个表格中的姓名和电话号码(可以是多个

号码),将它放在

数据库中的最佳方式是什么?问题围绕UserID并确保

tblPhones.UserID = tblUsers.UserID


感谢您的帮助!

Quick question for anybody who can help:

I have two tables:

tblUsers
--------
UserID
Name

tblPhones
---------
PhoneID
UserID
PhoneNumber

If I''m collecting the name and the phone numbers (can be multiple
numbers) in one form, what''s the best way of placing it in the
database? The question revolves around the UserID and making sure the
tblPhones.UserID = tblUsers.UserID

Thanks for any help!

推荐答案

哦是的... tblUsers.UserID在

数据库中自动递增...


MRW写道:
Oh yes... tblUsers.UserID is automatically incremented in the
database...

MRW wrote:

任何可以提供帮助的人的快速提问:


我有两张桌子:


tblUsers

--------

用户ID

名称


tblPhones

---------

电话号码

用户ID

PhoneNumber


如果我正在以一种形式收集姓名和电话号码(可以是多个

号码),那么什么是最好的将它放在

数据库中的方法?问题围绕UserID并确保

tblPhones.UserID = tblUsers.UserID


感谢您的帮助!
Quick question for anybody who can help:

I have two tables:

tblUsers
--------
UserID
Name

tblPhones
---------
PhoneID
UserID
PhoneNumber

If I''m collecting the name and the phone numbers (can be multiple
numbers) in one form, what''s the best way of placing it in the
database? The question revolves around the UserID and making sure the
tblPhones.UserID = tblUsers.UserID

Thanks for any help!


" MRW" < mw ***** @ yahoo.com写信息

news:11 ********************** @ 75g2000cwc。 googlegro ups.com ...
"MRW" <mw*****@yahoo.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...

对于任何可以提供帮助的人来说都是个问题:


我有两张桌子:


tblUsers

--------

用户ID

名称


tblPhones

---------

电话号码

用户ID

PhoneNumber


如果我正在以一种形式收集姓名和电话号码(可以是多个

号码),那么什么是最好的将它放在

数据库中的方法?问题围绕UserID并确保

tblPhones.UserID = tblUsers.UserID


感谢您的帮助!
Quick question for anybody who can help:

I have two tables:

tblUsers
--------
UserID
Name

tblPhones
---------
PhoneID
UserID
PhoneNumber

If I''m collecting the name and the phone numbers (can be multiple
numbers) in one form, what''s the best way of placing it in the
database? The question revolves around the UserID and making sure the
tblPhones.UserID = tblUsers.UserID

Thanks for any help!



UserID是否已知,或者您是否向tblUsers添加了一条记录?

为tblPhones提供了一条或多条记录?如果是前者,是tblUsers.UserID的身份

字段?如果是这样,您可以通过SELECT @@ IDENTIY或SELECT

SCOPE_IDENTITY来检索身份。然后你可以使用它将记录泵入tblPhones。

Is the UserID already known, or are you adding one record to tblUsers and
one or more to tblPhones? If the former, is tblUsers.UserID an identity
field? If so, you can retrieve the identity by SELECT @@IDENTIY or SELECT
SCOPE_IDENTITY. Then you can use that to pump the records into tblPhones.


基于你提到UserID是一个自动增加的字段的事实

,我假设这是一个IDENTITY,你的SQL中的SELECT

@@ IDENTITY应该为你做。


MRW写道:
Based on that fact that you mention that the UserID is an auto
incremented field, I am assuming this is an IDENTITY and the SELECT
@@IDENTITY in your SQL should do it for you.

MRW wrote:

对于任何可以提供帮助的人来说都是个问题:


我有两张桌子:


tblUsers

--------

用户ID

名称


tblPhones
---------

电话号码

用户ID

电话号码


如果我在一个表格中收集姓名和电话号码(可以是多个

号码),那么将其放入
$的最佳方式是什么? b $ b数据库?问题围绕UserID并确保

tblPhones.UserID = tblUsers.UserID


感谢您的帮助!
Quick question for anybody who can help:

I have two tables:

tblUsers
--------
UserID
Name

tblPhones
---------
PhoneID
UserID
PhoneNumber

If I''m collecting the name and the phone numbers (can be multiple
numbers) in one form, what''s the best way of placing it in the
database? The question revolves around the UserID and making sure the
tblPhones.UserID = tblUsers.UserID

Thanks for any help!


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆