Checking value in an array inside one SQL query with WHERE clause

前端 未结 4 620
萌比男神i
萌比男神i 2021-01-04 03:22

I want to know is this practically possible in sql(using php as server-side), where in you have an array of values(numbers), and you try to retrieve data based on values ins

4条回答
  •  别那么骄傲
    2021-01-04 03:57

    SQL can't parse PHP arrays. Try this:

    $query="SELECT * FROM posts WHERE user_id IN ({implode(',', $userIDarray)})";
    

提交回复
热议问题