bprosic 6 Light Poster

Hi,
i have two tables in mysql.
Tbl1 - lets call it {$tbl_p} has product_id and tax_id fields.
Tbl2 - lets call it {$tbl_c} has product_id and tax_id_w fields.

Tbl1 needs to be updated (only tax_id field) from Tbl2 based on values of tax_id_w field.
But, tax_id_w field in tbl2 has some empty values, NULL values, and I dont want to update this values into tbl1, I want to avoid them.
How to do that?
Product_id has the same values on both tables.

I have this code:

$sql_update_tax_products="UPDATE {$tbl_p} SET `tax_id`=(SELECT {$tbl_c}.tax_id_w FROM {$tbl_c} WHERE {$tbl_c}.product_id={$tbl_p}.product_id) WHERE {$tbl_p}.product_id=(SELECT {$tbl_c}.product_id FROM {$tbl_c} WHERE {$tbl_c}.tax_id_w!={$tbl_p}.tax_id AND {tbl_c}.tax_id_w IS NOT NULL)";

Any ideas? Currently I have no ideas :(

Many thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.