Reputation: 2279
I have two tables Token and distinctToken. Following is the description of the two tables.
Token (id int, text varchar(100), utokenid int)
distinctToken (id int, text varchar(100))
The text field in both tables have same data with one exception, that is text field in Token table contains repeated entries.
I wanted to update the Token table such that the utokenid it becomes a foreign key. To be more specific i want to set the value of Token.utokenid = distinctToken.id where Token.text is the same as distinctToken.text. Is it possible using update or should i write a stored procedure to do so.
Upvotes: 0
Views: 143
Reputation: 4359
UPDATE Token t, distinctToken dt SET t.utokenid = dt.id WHERE t.text = dt.text;
Am I missing something?
Upvotes: 2