Answer the question
In order to leave comments, you need to log in
How to specify the order in which records are stored in tables?
Is there a way to get a_id in the order they were inserted?
CREATE TABLE `m2m` (
`a_id` INT(11) NOT NULL,
`b_id` INT(11) NOT NULL,
PRIMARY KEY (`a_id`, `b_id`),
INDEX `FK_m2m_b` (`b_id`),
CONSTRAINT `FK_m2m_a` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK_m2m_b` FOREIGN KEY (`b_id`) REFERENCES `b` (`b`) ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
INSERT INTO `m2m` (a_id, b_id) VALUES ('1663', '4');
INSERT INTO `m2m` (a_id, b_id) VALUES ('1678', '4');
INSERT INTO `m2m` (a_id, b_id) VALUES ('1664', '4');
INSERT INTO `m2m` (a_id, b_id) VALUES ('1679', '4');
INSERT INTO `m2m` (a_id, b_id) VALUES ('1741', '4');
INSERT INTO `m2m` (a_id, b_id) VALUES ('1677', '4');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question