Create a stored procedure like this and tweak it to suit your case:
delimiter $$
drop procedure if exists clear_values$$
create procedure clear_values(subject char(10))
begin
declare finished int default 0;
declare colname varchar(100);
-- cursor
declare cur_columns cursor for
select column_name
from information_schema.columns
where table_name = 'test'
and data_type = 'char'
and character_maximum_length = 10;
-- data type and length matches the field info
-- in my table
-- handler for when we run out of records to read
declare continue handler for not found
set finished = 1;
open cur_columns;
reading: loop
-- retrieve data until end of records
fetch cur_columns into colname;
if finished = 1 then
leave reading;
end if;
-- create text that will update column's value
set @statement = concat(
'update test ',
'set `', colname, '` = \'\' ',
'where `', colname, '` = \'', subject, '\''
);
-- create a prepared statement from the text
-- and execute it
prepare stmt from @statement;
execute stmt;
deallocate prepare stmt;
end loop reading;
close cur_columns;
end$$
delimiter ;
When you get a chance, think about normalizing the table somewhat assuming this is a small project:
create table techs (
id int auto_increment primary key,
tech varchar(50)
);
create table schedules (
id int auto_increment primary key,
tech_id int not null,
sched datetime not null,
ticket char(6),
constraint fk_schedules_techs_tech_id
foreign key (tech_id)
references techs (id),
constraint uk_schedules_tech_id_sched
unique (tech_id, sched)
);
insert into techs (tech) values
('Joe'),
('Matt');
insert into schedules (tech_id, sched, ticket) values
(1, '2015-05-01 08:00:00', ''),
(1, '2015-05-01 09:00:00', ''),
(1, '2015-05-01 10:00:00', 'DSA123'),
(2, '2015-05-01 08:00:00', 'FGG324'),
(2, '2015-05-01 09:00:00', 'FGG324'),
(2, '2015-05-01 10:00:00', '');
http://sqlfiddle.com/#!9/19bc3/1
Now when you have to clear out ticket where the ticket was FGG324, you can type:
update schedules set ticket = '' where ticket = 'FGG324';