Eric Smith
Eric Smith

Reputation: 1376

Does the WHERE IN clause return results in the order of the array passed in?

If I were to run a sample query along the lines of:

SELECT songIDs FROM blah WHERE fileID IN($fileIDs)

Would MySQL always return songIDs in the order $fileIDs was passed in? I need to be able to have them matched up index for index

Upvotes: 0

Views: 35

Answers (2)

spencer7593
spencer7593

Reputation: 108400

No. A SELECT statement is not guaranteed to return rows in any specific order, absent an ORDER BY clause on the query.

(The one exception with MySQL is that a GROUP BY implies an ORDER BY on the same list of expressions in the GROUP BY clause.)

Upvotes: 1

Adriaan Stander
Adriaan Stander

Reputation: 166396

Simple answer is NO.

The result will be return in any order the databaser engine sees fit, unless you specify an ORDER BY

Upvotes: 2

Related Questions