CREATE TABLE test (
id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name,first_name)
);
1. SELECT * FROM test WHERE last_name='bob' and first_name='John';
2. SELECT * FROM test WHERE first_name='John' and last_name='bob';
The first sql must use index, however is the second use the index? and why?
VARCHAR, notCHAR(unless all names are expected to be exactly 30 chars long).