$array=array(1,3,4,20,55,88,125,1000); $string=implode(',',$array); $init=8; $mysqli->query("SELECT * FROM tbl WHERE set='$init' AND status IN ($string) LIMIT 2"); 

Is it possible to skip lines in the case of the already existing occurrence of a certain value? That is, if the first line

 id=1 set=8 status=1 

second

 id=2 set=8 status=1 

and the third

 id=3 set=8 status=3 

, is it possible to somehow modify the request to get records with id = 1 and id = 3?

    1 answer 1

    GROUP BY column_name returns the first rows from a selection with unique values ​​in the specified column.

     $mysqli->query("SELECT * FROM tbl WHERE set='$init' AND status IN ($string) GROUP BY status LIMIT 2");