Answers for "mysql where in array"

SQL
4

mysql where in array

-- SQL
SELECT * FROM table WHERE column IN('value1','value2','value3')

-- Javascript
$string="1,2,3,4,5";
$array=array_map('intval', explode(',', $string));
$array = implode("','",$array);
$query=mysqli_query($conn, "SELECT name FROM users WHERE id IN ('".$array."')");
Posted by: Guest on August-07-2020
1

select values from mysql using php array of ids

$sql = 'SELECT * 
          FROM `table` 
         WHERE `id` IN (' . implode(',', array_map('intval', $array)) . ')';
Posted by: Guest on June-27-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language