I am attempting to grab content where id = 3 OR id = 9 OR id = 100... Bear in mind, I may have a couple of hundred of those ids.
What's the most effective method to write my query?
$sql = "SELECT name FROM artists WHERE (id=3 OR id=9 OR .... id-100)"
.... WHERE id IN (3, 9, 100, ...)
You might want to make use of the [cde] function:
... WHERE id IN (3, 9, 100);
Check whether something is at some values ...
expr IN (value,...)if
1is equivalent to the values within the
exprlist, else returns
And call just the posts you'll need instead of using
SELECT * FROM table WHERE id IN (1, 2, 3 etc)
You should use SQL IN condition
SELECT * FROM table WHERE ID IN ('1', '2', '3', '4');
SELECT * FROM table WHERE id IN (1,2,5)
$sql = "Choose title FROM artists WHERE id REGEXP regex-pattern"