从mysql和php中的另一个表更新表,其中每列中没有NULL

I have the following tables

TableA.number_id

TableB.number_id

TableA.serial_id

TableB.serial_id

I want to update TableA.number_id with TableB number_id WHEN TableA serial_id == TableB serial_id except when TableA serial_id or TableB serial_id has no value i.e. is null or empty

This almost works except that I'm getting the first number_id inserted when TableA serial_id AND TableB serial_id has a NULL value, the "is not NULL" is being ignored.

$sql = "UPDATE TableA, TableB SET TableA.number_id = TableB.number_id WHERE TableA.serial_id = TableB serial_id AND TableA.serial_id IS NOT NULL";

Something like the following should do it:

UPDATE TableA a JOIN TableB b
  ON a.serial_id = b.serial_id
SET
  a.number_id = b.number_id
WHERE a.serial_id IS NOT NULL AND b.serial_Id IS NOT NULL

Good luck!