postgresql - SQL Using multiple joins to fill in null values -


i have 2 tables - 1 jobs data , 1 address data.

the address_data (d) follows:

| lotnumber | plannumber | streetnumber | (other info not relevant) |

the jobs_data (j): *for many of these entries, lot + plan number given

| lotnumber | plannumber | streetnumber | (other info) |

i want fill in j.streetnumber d.streetnumber field when null joining j.lotnumber = d.lotnumber , j.plannumber = d.plannumber

my first attempt:

insert jobs_data (streetnumber) select d.streetnumber address_data d join jobs_data j on j.lotnumber::varchar = d.lotnumber::varchar join address_data da on j.plannumber::varchar = da.plannumber::varchar j.streetnumber null ; 

within jobs_data (j) table, first attempt added blank row every row of address data (d) , filled in street number columns. further table, jobs data remained unchanged same missing street numbers.

also feeling null may not same empty streetnumber columns blank (with no spaces)?

i'm hoping sql gurus may able solve me!

also feeling null may not same empty streetnumber columns blank (with no spaces)?

if joins work (after simplification) whatever datatypes, fix above have fix clause follows:

insert jobs_data (streetnumber) select d.streetnumber address_data d join jobs_data j on j.lotnumber=d.lotnumber , j.plannumber=d.plannumber trim(j.streetnumber) null , trim(d.streetnumber) not null; 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -