0

I am trying to first select data from a row which contains certain characters. I would then like to update and append new data into another row of those items that were selected. This is my current solution I came up with when trying to combine the two tasks into a single query.

SELECT *
FROM `parts`UPDATE `parts` SET 
`keywords` = CONCAT(`keywords` , 'Phillips' )
WHERE INSTR(`name`, 'PHI') > 0
Daniel Hutmacher
9,1731 gold badge28 silver badges52 bronze badges
asked Feb 19, 2016 at 19:54
1
  • And ignore that there is no delimiter between the old keywords and 'Phillips'? Commented Feb 20, 2016 at 1:30

1 Answer 1

1

You can make a SELECT as part of an UPDATE statement, but you can't make an UPDATE part of a SELECT statement. However, based on your example you don't need to, instead you can just do the following:

UPDATE parts
SET keywords = CONCAT(keywords,'Phillips')
WHERE name LIKE '%Phi%'

If you want to retrieve the results after you've updated them just execute the following afterwards:

SELECT *
FROM parts
WHERE name LIKE '%Phi%'
answered Feb 19, 2016 at 21:07
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.