sql - Update one from two of duplicates in Firebird – more rows -


how update 1 2 or more duplicate rows? want keep 1 , update others new value.

simple example tables:

from

one|two|three ---------- 1|milk|water 1|milk|water 

to

one|two|three ---------- 1|milk|water 1|milk|sugar 

http://www.ibexpert.net/ibe/index.php?n=doc.themysteryofrdbdbkey

select *, rdb$db_key myexampletable; 

then

update myexampletable    set column=value   rdb$db_key=xxxxx; 

another approach using stored procedure (or execute block) , use sql cursor variables. require careful loop management, skip 1 row , change 2nd, third , on.

https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-psql-coding.html#fblangref25-psql-tbl-declare-cursor

also see examples update ... current of ... @ https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-dml-update.html#fblangref25-dml-tbl-update


but proper way add unique primary key column table , use unique numeric id


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -