Reputation: 413
Here I tried to get an array to my where_in sql query. but its not accessing the array.
user_id array is this
Array ( [0] => 87 [1] => 175 [2] => 181 [3] => 395 [4] => 1358 [5] => 1367 [6] => 1371 [7] => 1372 [8] => 1385 [9] => 1399 [10] => 1463 [11] => 1526 [12] => 1533 [13] => 1536 [14] => 1579 [15] => 1601 [16] => 1757 [17] => 1828 [18] => 1869 [19] => 2027 [20] => 2082 [21] => 2223 [22] => 2283 [23] => 2454)
query is this.
(SELECT user_id,COUNT(*) as total_count_ddh FROM `64_income_details` WHERE `user_id` IN $user_id GROUP BY `user_id`) as ddh";
it is return like this
(SELECT user_id,COUNT(*) as total_count_ddh FROM `64_income_details` WHERE `user_id` IN Array GROUP BY `user_id`) as ddh
Upvotes: 0
Views: 47
Reputation: 84
You can try in this way
$arr = array(87,175,181,395);
$user_id = implode(",",$arr);
(SELECT user_id,COUNT(*) as total_count_ddh FROM `64_income_details` WHERE `user_id` IN ($user_id) GROUP BY `user_id`) as ddh
I think it is helpful for you
Upvotes: 2