select place_id, count(*) from places_filter where filter_id IN ( 1, 100, 15 ,22) group by place_id HAVING count(*) = 4
set @addcoltext = concat('ALTER TABLE nick.mytable ADD COLUMN ',concat('day',dayofmonth(curdate() - interval 1 day)),' INTEGER UNSIGNED;');
prepare addcol from @addcoltext;
execute addcol;
deallocate prepare addcol;