+1  A: 

ON DELETE SET NULL

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

[CONSTRAINT [symbol]] FOREIGN KEY
    [index_name] (index_col_name, ...)
    REFERENCES tbl_name (index_col_name,...)
    [ON DELETE reference_option]
    [ON UPDATE reference_option]

reference_option:
    RESTRICT | CASCADE | SET NULL | NO ACTION

UPDATE: If you want to do it from the perspective of A table (why on earth would you want that???), then you can't get around a trigger, e. g.

DELIMITER ;;

CREATE TRIGGER tau_A AFTER UPDATE ON A
FOR EACH ROW    
BEGIN
    IF OLD.b_id_1 IS NOT NULL AND NEW.b_id_1 IS NULL;
    THEN
        DELETE FROM B WHERE id = OLD.b_id_1;
    END IF;
    IF OLD.b_id_2 IS NOT NULL AND NEW.b_id_2 IS NULL;
    THEN
        DELETE FROM B WHERE id = OLD.b_id_2;
    END IF;
END;;

Anyway, that won't set to NULL any values in A that have the same value, because you cannot make a trigger in MySQL, that changes the same table that triggered the trigger.

And generally, if you want weird stuff like this, I can assert with high probability that your database design is flawed. If you put more details, I could perhaps suggest a better one.

codeholic
@codeholic I forgot to add one important thing. THE QUERY SHOULD BE EXECUTED FROM THE PERSPECTIVE OF A TABLE! Yes, if we use this On delete set null and delete a record from B table it will work. But the query MUST touch only A table !!
EugeneP
@EugeneP: I've updated my answer.
codeholic
@codeholic Thank you, it was not an easy question and your solution looks pretty.
EugeneP
@codeholic. Well why on earth I need that. I thought it could simplify my programming model, so that I can manage only "A" table object. But now I will think twice, and maybe set to null will be a simpler solution.
EugeneP