I'm trying to grab content where id = 3 OR id = 9 OR id = 100... Keep in mind, I can have a few hundred of these ids.
What is the most efficient way to write my query?
$sql = "SELECT name FROM artists WHERE (id=3 OR id=9 OR .... id-100)"
It is possible to use a different MySQL server binary per instance, or use the same binary for multiple instances, or any combination of the two approaches.
You can specify multiple conditions in a single WHERE clause to, say, retrieve rows based on the values in multiple columns. You can use the AND and OR operators to combine two or more conditions into a compound condition.
To select multiple values, you can use where clause with OR and IN operator.
MySQL also supports the execution of a string containing multiple statements separated by semicolon ( ; ) characters. This capability is enabled by special options that are specified either when you connect to the server with mysql_real_connect() or after connecting by calling mysql_set_server_option() .
.... WHERE id IN (3, 9, 100, ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With