foreign key (test_id, question_id)
references test_question(test_id, question_id)
on delete cascade
PARTITION BY RANGE(YEAR(updated))
SUBPARTITION BY HASH(status)
SUBPARTITIONS 4 (
PARTITION p0 VALUES LESS THAN (2000),
PARTITION p1 VALUES LESS THAN (2010),
PARTITION p2 VALUES LESS THAN MAXVALUE
);
delimiter $$
drop function if exists `last_images_names`$$
create function `last_images_names` (aid int, ilimit int)
returns varchar(255)
reads sql data
begin
return (select group_concat(`name`) from (
select `name` from `images` where `album_id` = aid
order by `image_id` desc limit ilimit
) as _i);
end$$
delimiter ;
select `name`, last_images_names(`id`, 5) from `albums` order by `album_id` desc limit 10;