请帮我解决此更新查询。我完全理解这是多余的,但我需要它。 当用户创建一个仅包含ID,用户名,密码和客户ID的用户帐户时,我必须在客户创建自己的记录中创建一条记录,但是所有内容都为null,而User.User_Customer_ID必须更新为新创建的Customer.Customer_ID
我有一切正常但这个讨厌的更新查询。它需要做的唯一事情就是将User.User_Customer_ID更改为Customer.Customer_ID我设法将User.User_ID更改为一个名为UserID的整数,而Customer.Customer_ID就是一个名为CustomerID的整数,我尝试了一百万种不同的方法但没有成功
以下是我尝试过的众多查询之一。
1. UPDATE [User]
SET User_Customer_ID = Customer.Customer_ID
FROM Customer
WHERE [User].User_ID = '16'
AND Customer.CUstomer_ID = '19'
( ? would be the integer UserID and CustomerID )
以下是它在插入VB
中的SQL命令之前的样子 UpdateUserCustomerID = "UPDATE [User] SET User_Customer_ID = Customer.Customer_ID FROM Customer WHERE ([User].User_ID ='" & UserID & "' AND Customer.Customer_ID = '" & CustomerID & "')"
Access Database / ASP.Net / VB
Table:
Customer:
Customer_ID
Customer_First_Name
Customer_Last_Name
Customer_Street_Address
Customer_City
Customer_State
Customer_Zip
Customer_Email
User:
User_ID
User_UserName
User_Password
User_Customer_ID
答案 0 :(得分:2)
我似乎不太可能ID是文本字段(列),如果它们是数字字段,则引号是问题之一。
据我所知,这是:
"UPDATE [User] SET User_Customer_ID = Customer.Customer_ID FROM Customer WHERE ([User].User_ID ='" & UserID & "' AND Customer.Customer_ID = '" & CustomerID & "')"
应该是:
"UPDATE [User] SET User_Customer_ID = " & CustomerID _
& " WHERE ([User].User_ID = " & UserID