这是我的 GRASS GIS 数据库命令(使用 SQL Lite 驱动程序):
db.execute sql="UPDATE streams_order SET factor=next_stream WHERE number IS NOT NULL AND next_stream IN (SELECT number FROM streams_order)"
但我想要
db.execute sql="UPDATE streams_order SET factor=next_stream WHERE number IS NOT NULL AND next_stream NOT IN (SELECT number FROM streams_order)"
结果应该是:
+---------+--------------+--------+---------+
| stream | next_stream factor | number |
+-------------------------------------------+
370 -1
372 370 370 372
374 440
376 372 376
380 374 374 380
.............................................
它无法在没有任何错误的情况下工作:运行命令后“factor”列为空。如果我放进去效果很好。列类型均为 INT。
包含真实数据的沙箱在这里https://dbfiddle.uk/zg8_xJUz