小表驱动大表 优化原则:小表驱动大表,即小的数据集驱动大的数据集。SELECT * FROM A WHERE id IN (SELECT id FROM B)
等价于:
for SELECT id FROM B
for SELECT * FROM A WHERE A.id = B.id
当数据表B的数据集小于A表时,用I...
准备CREATE TABLE IF NOT EXISTS `class`(
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`card` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `book`(
`boo...