开发者

Update with multiple rows

开发者 https://www.devze.com 2023-02-22 08:37 出处:网络
i am using UPDATE to update all records in the table with value from another table: UPDATE x.ADR_TEMP SET LOCATIONID = (SELECT ID FROM x.OBJECTRELATIONSHIP WHERE PROPERTYCLASS = \'PHYSICALLOCATION\')

i am using UPDATE to update all records in the table with value from another table:

UPDATE x.ADR_TEMP SET LOCATIONID = (SELECT ID FROM x.OBJECTRELATIONSHIP WHERE PROPERTYCLASS = 'PHYSICALLOCATION')

in both tables are the same number of records. I just need to read id from one table and put them into another.

I 开发者_StackOverflow社区have error: ORA-01427: single-row subquery returns more than one row

I am new in this subject and suspect that solution is very simple. Please help me


UPDATE x.ADR_TEMP SET LOCATIONID = (
                                     SELECT ID 
                                     FROM x.OBJECTRELATIONSHIP 
                                     WHERE PROPERTYCLASS = 'PHYSICALLOCATION' AND x.ADR_TEMP.relatedKey = x.OBJECTRELATIONSHIP.relatedKey )

if your tables are related to each other with some way like this(relatedKey is a column which relates to the second table mentioned), you can try this one.(not sure or perfect)

0

精彩评论

暂无评论...
验证码 换一张
取 消