I have two tables Token and distinctToken. Following is the description of the two tables.
<strong>Token</strong> (id int, text varchar(100), utokenid int)
<strong>distinctToken</strong> (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 <strong>Token.utokenid = distinctToken.id</strong> where <strong>Token.text is the same as distinctToken.text</strong>. Is it possible using update or should i write a stored procedure to do so.Answer1:
UPDATE Token t, distinctToken dt SET t.utokenid = dt.id WHERE t.text = dt.text;
Am I missing something?