user3522145
user3522145

Reputation: 101

MySQL select update subquery with where

I have table cps2sql with fields 'Spanish_SID' and 'Spanish_Word', and table spanish with corresponding fields 'SID' and 'word'.

I want to update cps2sql setting cps2sql Spanish_Word to spanish word.

So I have the following update query:

update cps2sql
SET c.Spanish_Word=s.word (
SELECT c.word, s.word
FROM cps2sql c, spanish s
WHERE c.Spanish_SID = s.SID)

Is there anything wrong/risky with this?

Thank you.

Upvotes: 0

Views: 41

Answers (1)

Blank
Blank

Reputation: 12378

You can use update join:

update cps2sql c
join spanish s 
on c.Spanish_SID = s.SID
set c.Spanish_Word = s.word

Upvotes: 1

Related Questions