Hi, In the first key, the combination of key1 and key2 must be unique, in the second, key1 must be unique on its own, but key2 does not need to be.
Also, using the first primary key a select col1, col2, ... where key2=value cannot use the index but select col1, col2, ... where key1=value can In the second example, either query may use an index. You can search on any column - makeing the column and index (or the left-most part of an index) allows the index to be used to make the search faster. MySQL Doesn't allow you to specifiy which index to use - it chooses (sometimes badly) whether or not to use one. Hope this helps. Quentin -----Original Message----- From: Federico Schwindt [mailto:[EMAIL PROTECTED]] Sent: Thursday, 1 November 2001 10:57 a.m. To: [EMAIL PROTECTED] Subject: key question hi, i'm not sure if this belongs here, but i cannot seem to find the answer anywhere else. first, what's the difference between: PRIMARY KEY (key1, key2) PRIMARY KEY (key1), KEY (key2) second, let's suppose the following table: owner_id int(11), customer_id int(11), customer_info varchar(100) and i want to search either by owner_id and customer_id. can i do this w/o creating the indexes by hand? or do i have to create'em explicity and specify which one i'm gonna use before performing a query? if anyone can help me or point me to where i can find this kind of stuff i'd appreciate it. thanks, f.- --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php The information contained in this email is privileged and confidential and intended for the addressee only. If you are not the intended recipient, you are asked to respect that confidentiality and not disclose, copy or make use of its contents. If received in error you are asked to destroy this email and contact the sender immediately. Your assistance is appreciated. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php