Postgresql 即使查询返回多行,也只更新一行

Postgresql 即使查询返回多行,也只更新一行,postgresql,python-2.7,Postgresql,Python 2.7,我是psql新手,正在尝试更新一个类似于以下内容的表: Command | Expected | Actual show interfaces queue xe-1/1/2 | Queue: 0, Forwarding classes: CVX-Internet | show interfaces queue xe-1/1/2 | Packets | show interfaces queue xe-1/1/2 | Bytes | show interfaces queue xe-1/1/

我是psql新手,正在尝试更新一个类似于以下内容的表:

Command | Expected | Actual
show interfaces queue xe-1/1/2  | Queue: 0, Forwarding classes: CVX-Internet |
show interfaces queue xe-1/1/2  | Packets |
show interfaces queue xe-1/1/2  | Bytes |
show interfaces queue xe-1/1/2  | Queue: 1, Forwarding classes: CVX-VoIP |
show interfaces queue xe-1/1/2  | Packets |
show interfaces queue xe-1/1/2  | Bytes |
但当我说更新时:

UPDATE table SET Actual = 'Packets:10' WHERE Command = 'show interfaces queue xe-1/1/2' AND Expected = 'Packets';
它在两个地方得到更新

我想要一个解决方案,在该解决方案中,我可以将光标保持在前一行,并且仅当前一行包含“Queue:0”之类的值时,才更新包含“packets”的相应下一行。
请帮助。

是否将错误的内容粘贴到表格数据中?因为你发布的内容毫无意义。我还认为您需要更详细地解释您的问题。在关系数据库中,没有下一行/上一行这样的东西,因为行顺序是未定义的。如果有其他有意义的排序(例如时间戳),则需要将其加载到自己的列中,然后您可以使用该列选择行。谢谢Daniel和Craig。我通过在预期列中的“Packets”和“Bytes”前面粘贴相应的“Queue:?”来解决问题,这样我现在就可以区分它们,并将我的UPDATE语句修改为“…和预期的类似“Queue:0,Packets”。