MYSQL OR vs IN performance

I am wondering if there is any difference with regards to performance between the following

SELECT ... FROM ... WHERE someFIELD IN(1,2,3,4)

SELECT ... FROM ... WHERE someFIELD between 0 AND 5

SELECT ... FROM ... WHERE someFIELD = 1 OR someFIELD = 2 OR someFIELD = 3 ... 

or will MySQL optimize the SQL in the same way compilers optimize code?

EDIT: Changed the AND‘s to OR‘s for the reason stated in the comments.

14 Answers
14

Leave a Comment