How to Use IN operator

I want to use IN operator in sql query please suggest the correct syntax. code snippest is just example.

Problem is who to use $selectedusers[] array in Query using IN operator.

[COLOR=“SeaGreen”] $sql = “select userid from tblprojuser where projid = ‘$sprojid’”;
$result = mysqli_query($link, $sql);

while ($row = mysqli_fetch_array($result))
{$selectedusers[] = $row['userid'];}[/COLOR]

[SIZE="4"]//selecte all application users excluding those in [COLOR="red"]$selectedusers[][/COLOR] array 
[COLOR="Red"]$sql = "select id, username, status from tbluser where id NOT IN ($selectedusers)";	[/COLOR][/SIZE]

$sql = "select id, username, status from tbluser where id NOT IN (" . implode(",", $selectedusers) . ")";

If you don’t need the result of your first query for anything else, you can do it with one query:


SELECT
    id
  , username
  , status
FROM tbluser
LEFT OUTER JOIN tblprojuser
ON userid = id
AND projid = '$sprojid'
WHERE userid IS NULL