Home > database >  Through the associated conditions, using the data of a table to another table completion information
Through the associated conditions, using the data of a table to another table completion information

Time:09-29

there are two tables gl_cxjylsb_ls a, gl_zhdzb e
A.Z HKHYBT=e.N BZH is matching conditions

as a table SFZH has many null values, I want to achieve when SFZH not null output SFZH, null values, the output by matching the conditions in the table e ZJHM to complement the value of the corresponding SFZH

So how to realize the sigh

CodePudding user response:




As shown in the above, when SFZH is empty, will increase to the corresponding data in a ZJHM SFZH

CodePudding user response:

The select NVL (a.s FZH, e.z JHM) fromgl_cxjylsb_ls a, gl_zhdzb e where a.Z HKHYBT=e.N BZH

CodePudding user response:

The select NVL (a.s FZH, e.z JHM) from gl_cxjylsb_ls a, gl_zhdzb e where a.Z HKHYBT=e.N BZH

CodePudding user response:

The select NVL (a.s FZH, e.z JHM), a.Z HKHYBT from gl_cxjylsb_ls a left join gl_zhdzb e on a.Z HKHYBT=e.N BZH

CodePudding user response:

UPDATE A SET A.S FZH=(SELECT SFZH FROM (SELECT SFZH, NBZH FROM B) T WHERE A.Z HKHYBT=T.N BZH) WHERE A.S FZH IS NULL

CodePudding user response:

Using the NVL function matching vacancy, then use the subquery find out the value of the corresponding table b
  • Related