Skip to main content
8 events
when toggle format what by license comment
Sep 16, 2017 at 18:30 comment added indiri If it does not have a unique constraint then include a line in the subquery to limit it to 1 result
Sep 16, 2017 at 17:46 comment added stefan Updating the subquery (containing the join) only works if the users table has this constraint (it's a built-in restriction). It was just an example. The new ids must go somewhere - I did not want to overwrite existing values.
Sep 16, 2017 at 17:39 comment added indiri Also your dbfiddle does not seem to match the original question. The original question said that username and email are mixed in the same column is user_details but in fiddle they are separate columns. Also in the original you were updating user_details.username=users.id but now you want to use a new column and put the user_details.user_id=users.id. The attached fiddle does not have any situations where there would be more than one users.id that matches.
Sep 16, 2017 at 17:35 comment added indiri If you take UNIQUE out of users in the dbfiddle? So you mean that multiple users may have the same email address. In that case (more than one user has that email) are you intending to just pick whichever one is first? Or do you not want to do the update if there is more than 1?
Sep 16, 2017 at 17:15 comment added stefan dbfiddle.uk/…
Sep 16, 2017 at 17:04 comment added indiri When there is more than 1 then how are you determining which one you want?
Sep 16, 2017 at 17:03 comment added stefan If there is more than one users.sid, we'll get a "ORA-01427: single-row subquery returns more than one row." (Although: at the first glance I thought your UPDATE should do the job :-))
Sep 14, 2017 at 21:15 history answered indiri CC BY-SA 3.0