Reputation: 259
Newbie warning (yes I looked for answer):
I have a substring query to get first word from FieldA
SELECT SUBSTRING_INDEX( field
, ' ', 1 ) AS field_first_word
FROM your_table
and am trying to write that to FieldB
update yourtable set fieldB = (above string)
doing an update tells me I can't use yourtable in the from command.
Upvotes: 0
Views: 62
Reputation: 125855
You can use your expression on FieldA
directly within the SET
clause of the UPDATE
command:
UPDATE your_table SET FieldB = SUBSTRING_INDEX(FieldA, ' ', 1)
Upvotes: 1