I have a database with one table, let's say 'tablename'. Now, I want the first column of that table, named 'text' to be updated with the text it containts PLUS some new text which comes as result from another query executed over 'tablename2'. So, I want something like this:
UPDATE tablename SET text="current text" + (SELECT * FROM tablename2 where ID=12);If 'text' value is 'Result not available' I want toappend ' here', so that the field value is 'Result not available here'
How is this possible? Thanks
- see thisUpdate query in Sqlite answer , solved my problemabbasalim– abbasalim2017-11-24 15:18:47 +00:00CommentedNov 24, 2017 at 15:18
2 Answers2
Try the concatenation operator (||):
UPDATE tablename SET text='current text'||(SELECT * FROM tablename2 where ID=12);And I'm not sure, but you should use ' instead of " .
2 Comments
I probably misunderstood your question, but let's try:
http://sqlfiddle.com/#!5/959e5/2
UPDATE Table1SET text = text || CASE WHEN text = 'Result not available' THEN ' here' ELSE (SELECT text FROM Table2 where id = 12) END;
