0

I use MySQLi prepared statements. Which is better:

  1. WHERE row=? and execute as many times as many values
  2. WHERE row IN (?, ?, ?) bind as many times as many values

EDIT: Table has ~20k rows and I may want to look for 1-20k values in that field (all 20k makes no sense, of course).

Martin
  • 1,312
  • 1
  • 15
  • 18

2 Answers2

0

I am using IN all the time more readable and more maintainable than the first. Performance based IN clause is much better.

Read more here

Prince Jea
  • 5,524
  • 7
  • 28
  • 46
0

IN is fine it is optimized. But make sure you use it on an indexed column. It's functionally equivalent to (where : a=1 OR a=2 OR a=3).

BaN3
  • 435
  • 1
  • 3
  • 16