开发者

Update with multiple rows

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜