Javier,
Tuesday, March 12, 2002, 3:04:21 PM, you wrote:

J> I have a table like that

J> table1:
J>   field1
J>   field2
J>     .
J>     .
J>     .

J> where :

J> field1,field2

J>  is the primary key.

J> When I make this query:

J> SELECT  *  FROM table1 USE INDEX(PRIMARY)

J> I get a different result, if I make this:

J> SELECT  *  FROM table1 ORDER BY field1,field2

J> Why? Is not the same?

I suggest you to use EXPLAIN SELECT to get info about SELECT. Look at:
  http://www.mysql.com/doc/E/X/EXPLAIN.html

"SELECT  *  FROM table1 USE INDEX(PRIMARY)" doesn't use index for
sorting rows and displays rows in internal order (non-guaranteed). 
"SELECT  *  FROM table1 ORDER BY field1,field2" uses field1 and field2
for sorting.

J> What is the default order, that MySQL use if for this table, I make : SELECT
J> *  FROM table1

By default rows are listed in order in which they are stored in the table.

You can read about sorting rows in MySQL if you look at:
    http://www.mysql.com/doc/S/o/Sorting_rows.html

Read about how MySQL uses indexes at:
    http://www.mysql.com/doc/M/y/MySQL_indexes.html
    
J> Javier Diaz
J> IT Developer






-- 
For technical support contracts, goto https://order.mysql.com/
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com



---------------------------------------------------------------------
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

Reply via email to