D
D
Dmitry Khaperets2016-09-15 19:07:41
MySQL
Dmitry Khaperets, 2016-09-15 19:07:41

Strange MySQL behavior: sorting of results depends on select?

MySQL 5.5 is used.
When requested:

SELECT id, name FROM products WHERE some_id = 48 AND another_id = 1 ORDER BY product_sort desc

there is only one sorting of results, and when querying:
SELECT * FROM products WHERE some_id = 48 AND another_id = 1 ORDER BY product_sort desc

- another. Why is this so, and how can I make sure that when select * the sorting of the results is the same as in the first query?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Edward, 2016-09-15
@Khaperets

these are two different queries, and product_sort is most likely not very unique. so the records with the same product_sort are displayed in random order. For example, in the first case, the index was read, and in the second, the clustered index.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question