Afficher un message
Vieux 15/03/2008, 23h42   #1
Nacho Garcia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how to use index with order by here

Hi, im having troubles with one query, hope someone can .

on this table:

messages:
id_from int(10)
id_to int(10)
text varchar(1000)
time

with index on id_form and id_to

i want to get messages sent from one user to another and vice versa order by
time.
let say we want to search messages between user 1 and 2:
i'm doing:

SELECT *
FROM messages
WHERE id_from in (1,2)
AND id_to in (1,2)
ORDER BY time

but that gives me a filesort in all rows matching the where clause, and
thats not good. I tried by indexing id_from, id_to, time but thats not
working of course.

any would be really appreciate.

  Réponse avec citation
 
Page generated in 0,04789 seconds with 9 queries