create schema test_crash;
use test_crash
CREATE TABLE `a` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;
CREATE TABLE `b` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `a_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `a_id` (`a_id`),
  CONSTRAINT `a_id` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`)
) ENGINE=InnoDB;
insert into a (name) values ("a"), ("b"), ("c");
insert into b (name, a_id) values ("a1", 1), ("a2", 1), ("a3", 1), ("b1", 2), ("c1", 3), ("c2", 3), ("c3", 3);
delete b from a join b on b.a_id=a.id where a_id in (select distinct * from (select a.id from a join b on b.a_id=a.id limit 2) as x);

