Hey

I am using a trigger, if the trigger returns emtpy I want it to keep the data it already has.

This is my trigger:

BEFORE INSERT
SET NEW.calling_num = (SELECT users_name FROM cdr_phone_system_data WHERE extension_number = NEW.calling_num);

How can I check if the return is blank? The idea is so we either match the number with a name or we show the number. It should never be blank.

Many Thanks

Chris.

Im a little confused on the scenario, but maybe this will get you close?

BEFORE INSERT
SET NEW.calling_num = (SELECT CASE users_name WHEN '' THEN NEW.calling_num ELSE extension_number FROM cdr_phone_system_data WHERE extension_number = NEW.calling_num);
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.