Partition Selection PARTITION ( partition_names ) partition_names : partition_name , ... SET @@SQL_MODE = ’’; CREATE TABLE employees ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, fname VARCHAR(25) NOT NULL, lname VARCHAR(25) NOT NULL, store_id INT NOT NULL, department_id INT NOT NULL ) PARTITION BY RANGE(id) ( PARTITION p0 VALUES LESS THAN (5), PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (15), PARTITION p3 VALUES LESS THAN MAXVALUE ); INSERT INTO employees VALUES (’’, ’Bob’, ’Taylor’, 3, 2), (’’, ’Frank’, ’Williams’, 1, 2), (’’, ’Ellen’, ’Johnson’, 3, 4), (’’, ’Jim’, ’Smith’, 2, 4), (’’, ’Mary’, ’Jones’, 1, 1), (’’, ’Linda’, ’Black’, 2, 3), (’’, ’Ed’, ’Jones’, 2, 1), (’’, ’June’, ’Wilson’, 3, 1), (’’, ’Andy’, ’Smith’, 1, 3), (’’, ’Lou’, ’Waters’, 2, 4), (’’, ’Jill’, ’Stone’, 1, 4), (’’, ’Roger’, ’White’, 3, 2), (’’, ’Howard’, ’Andrews’, 1, 2), (’’, ’Fred’, ’Goldberg’, 3, 3), (’’, ’Barbara’, ’Brown’, 2, 3), (’’, ’Alice’, ’Rogers’, 2, 2), (’’, ’Mark’, ’Morgan’, 3, 3), (’’, ’Karen’, ’Cole’, 3, 2); mysql>  SELECT * FROM employees PARTITION (p1); +----+-------+--------+----------+---------------+ When the  PARTITION  option is used, only the partitions and subpartitions listed are checked for matching rows. This option can be used in a  SELECT  statement to determine which rows belong to a given partition. Consider a partitioned table named  employees , created and populated using the statements shown here: This option always follows the name of the table to which the partition or partitions belong. partition_names  is a comma-separated list of partitions or subpartitions to be used. Each name in this list must be the name of an existing partition or subpartition of the specified table; if any of the partitions or subpartitions are not found, the statement fails with an error ( partition ’ partition_name ’ doesn’t exist ). Partitions and subpartitions named in  partition_names  may be listed in any order, and may overlap. You can see which rows are stored in partition  p1  like this: | id | fname | lname | store_id | department_id | +----+-------+--------+----------+---------------+ | 5 | Mary | Jones | 1 | 1 | | 6 | Linda | Black | 2 | 3 | | 7 | Ed | Jones | 2 | 1 | | 8 | June | Wilson | 3 | 1 | | 9 | Andy | Smith | 1 | 3 | +----+-------+--------+----------+---------------+ 5 rows in set (0.00 sec) The result is the same as obtained by the query  SELECT * FROM employees WHERE id BETWEEN 5 AND 9 . To obtain rows from multiple partitions, supply their names as a comma-delimited list. For example, SELECT * FROM employees PARTITION (p1, p2)  returns all rows from partitions  p1  and  p2  while excluding rows from the remaining partitions. 4709