我有3個表:我想更新現有記錄我該怎麼辦?
CREATE TABLE employee(
presismail varchar(50) NOT NULL,
name varchar (50),
lastname varchar (50),
CONSTRAINT presismail PRIMARY KEY (presismail))
CREATE TABLE users(
usermail varchar(50)NOT NULL,
nomail varchar (2),
CONSTRAINT usermail PRIMARY KEY (usermail))
CREATE TABLE assignment(
presismail varchar(50)NOT NULL,
usermail varchar(50)NOT NULL,
senddates varchar (20)NOT NULL,
answervalue varchar (3),
receivedates varchar (20)
CONSTRAINT PK_assignment PRIMARY KEY (presismail, usermail, senddates),
FOREIGN KEY (presismail) REFERENCES employee(presismail),
FOREIGN KEY (usermail) REFERENCES users(usermail))
我想創建一個StoredProcedure的,增加值到已選定2列。
insert into assignment(answervalue, receivedates)
values (@answervalue, @receivedates)
select answervalue, receivedates
from assignment
where presismail = @presismail
and usermail = @usermail
and senddates = @senddates
我該怎麼做?
你的問題不清楚,你可以給樣品記錄嗎? –
您正在使用哪些DBMS? –