How to copy records from one table to another, and then update one field with data from another table using sql queries? There are three tables:

CREATE TABLE [vedomost] ( [id] INTEGER PRIMARY KEY, [fio] VARCHAR(80), [dolgnost] VARCHAR(80), [stavky] FLOAT, [work_days] INTEGER, [shtraf] FLOAT, [nalog] FLOAT, [prochee] FLOAT, [avans] FLOAT, [premija] FLOAT, [month] VARCHAR(30), [year] INTEGER, [point] VARCHAR(80), [n_month] INTEGER, [status] BOOLEAN); CREATE TABLE [dolgnosty] ( [id] INTEGER PRIMARY KEY, [dolgnost] VARCHAR(80)); CREATE TABLE [stavky] ( [id] INTEGER PRIMARY KEY, [dolgnost] VARCHAR(80), [stavka] FLOAT, [year] VARCHAR(30), [month] VARCHAR(30), [point] VARCHAR(80), [n_month] INTEGER); 

The question is as follows. It is necessary to copy from the dolgnosty table all the values ​​of the [dolgnost] field into the stavky table, and then in the stavky table, insert the values ​​into the [stavka] field from the vedomost table, from the [stavky] field.

    2 answers 2

     INSERT INTO stavky (id, dolgnost) SELECT DISTINCT id, dolgnost FROM dolgnosty 

    The second request is similar to small remarks 1) in stavky the title of the post is probably superfluous 2) is it not enough - all of a sudden foreigners will watch your programs. ids are better to give in english

      The task is set incorrectly, due to the incorrect structure. There is no need to insert anything anywhere if foreign keys are correctly defined. For example, [stavky]. [Dolgnost] should be a foreign key to the dolgnosty table and have an int type, respectively. Etc.