in reply to fetching data from MySQL

a)
SELECT word FROM tablename ORDER BY id ASC
b)
ALTER TABLE tablename ADD INDEX(line_n); ALTER TABLE tablename ADD INDEX(word_position); ALTER TABLE tablename ADD INDEX(line_n,word_position); SELECT word FROM tablename USE INDEX(line_n,word_position) ORDER BY (l +ine_n*100+word_position) ASC;
version b) looks more complicated, but it makes you independent from the identifiers.
--------------------------------
masses are the opiate for religion.

Replies are listed 'Best First'.
Re^2: fetching data from MySQL
by samtregar (Abbot) on Apr 27, 2008 at 16:11 UTC
    There's no need to do multiplication tricks in the ORDER BY - MySQL supports ordering by multiple columns. Also, due to the way MySQL uses indexes you don't need separate (line_n) and (line_n,word_position) indexes. A query that could use the first index will be able to use the second one just as well.

    -sam