0

I have a table SESSIONS and I am adding a new field ContentId to this table. CONTENTs is a new table being created in the upgrade/migration script too. before a foreign key constraint is added, I need to set the values of COntentId in the SESSIONS table based upon the data in the newly created and populated table CONTENTS.

The content table has some backward compatibilty data inserted into it, such that one content is associated with one session. (Though in future, a content might have multiple sessions)

This is my query:

UPDATE ModuleSessions MS 
SET ModuleContentId = 
  (SELECT ID FROM ModuleContent MC WHERE 
  Name = CONCAT('Content For Session ', MS.Id))

It is unhappy about the MS.Id (Incorrect Syntax near 'MS')

Maybe there is a better way to do the subquery to get the value to update the SESSION?

Steve-o169
  • 2,066
  • 1
  • 12
  • 21
Simon
  • 736
  • 6
  • 21

0 Answers0