0

I am trying to do the following:

update mytable 
set fullname = anothersource.firstname ||' '|| anothersource.lastname
where
userid = anothersource.userid
;

I am having errors which I am not pasting because it make not sense since I simplified the example, however, is there a special way of handling updates with information from different sources? I believe that may be where problem lives.

Thanks

2 Answers 2

1

You need a subquery for Oracle:

update mytable 
    set fullname = (select anothersource.firstname ||' '|| anothersource.lastname
                    from anothersource
                    where mytable.userid = anothersource.userid
                   );

If there is the danger that the subquery might return more than one row, then use an aggregation (such as min() or where rownum = 1).

Sign up to request clarification or add additional context in comments.

Comments

0
UPDATE mytable
SET  fullname =
     (SELECT firstname FROM anothersource WHERE user_id = user_id)
     ||' '||
     (SELECT lastname FROM anothersource1 WHERE user_id = user_id)
WHERE mytable_id = id;

Comments

Your Answer

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.