New answers tagged


(Diff issue) Here's a guess as to why the second SELECT shows only one row... The optimizer notices when a column (or set of columns) is declared UNIQUE. In that case it can stop scanning rows after the first one it finds.


My thought is that the constraints were disabled during the load. This allows for faster insert of data but can cause issues like this. If you have UNIQUE constraints on secondary keys, you can speed up table imports by temporarily turning off the uniqueness checks during the import session: SET unique_checks=0; ... SQL import statements ... SET ...


If I've understood you correctly, what you want is something like this: CREATE TABLE Example ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, UNIQUE KEY uix_name_example (name) ); The id field is the PRIMARY KEY and its value is taken care of by the server. A UNIQUE KEY on name ensures no duplicates are allowed - and NOT NULL ...


Put a copy of B and C in the range field (as an extra column) and make that your range key like "B_C" and you can still also have separate columns for B and C if you need.

Top 50 recent answers are included