How to update column in one table from another if both tables have a text field in common


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.


UPDATE Token t, distinctToken dt SET t.utokenid = dt.id WHERE t.text = dt.text;

Am I missing something?


  • ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking
  • Generic DB Table
  • MS SQL Server 2008 :Getting start date and end date of the week to next 8 weeks
  • Populate ArrayList from Stored Procedure result set
  • PHP PDF generation problem
  • How to move comma seperated ids from one row to another row?
  • Windows batch string manipulation in loop
  • How to find data from last week in MySQL
  • Migrating row from one table to another with conditions [MYSQL]
  • SQL Server Like Query not case sensitive
  • Sql indexes vs full table scan
  • mysql table locked after php crashes
  • Sort by a column in a union query in SqlAlchemy SQLite
  • Sum values in array of hash if they have the same value
  • Syntax error near unexpected token 'elif'
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • read values from form post in jquery or javascript
  • Identifier too long in Oracle
  • XSLT foreach repeating nodes to flat
  • Azure table store snapshot/backup capability
  • Bigquery event streaming and table creation
  • Eliminate partial duplicate rows from result set
  • Linq Objects Group By & Sum
  • Retrieving value from sql ExecuteScalar()
  • javascript inside java/jsp code
  • Large data - storage and query
  • Delete MySQLi record without showing the id in the URL
  • Unanticipated behavior
  • Comma separated Values
  • Android Studio and gradle
  • KeystoneJS: Relationships in Admin UI not updating
  • Hits per day in Google Big Query
  • Trying to get generic when generic is not available
  • embed rChart in Markdown
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Checking variable from a different class in C#
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can i traverse a binary tree from right to left in java?
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app