Join myql query with array : i have mysql table like this

table test

    | idx|  name  | year | month |
    +----+--------+------+-------+
    | 1  |  foo-u | 2019 | 1     |
    | 2  |  foo-v | 2019 | 2     |
    | 3  |  foo-w | 2019 | 3     |
    | 4  |  foo-x | 2019 | 1     |
    | 5  |  foo-y | 2019 | 2     |
    | 6  |  foo-z | 2019 | 3     |

and array like this

    $qty = array("1"=>"42", "4"=>"44", "5"=>"54"); //result from unserialize data

how can i join mysql query and $qty array with result like this

    | idx|  name  | year | month |  qty |
    +----+--------+------+-------+------+
    | 1  |  foo-u | 2019 | 1     |  42  |
    | 4  |  foo-x | 2019 | 1     |  44  |
    | 5  |  foo-y | 2019 | 2     |  54  |


i tried like this

    <?php
    foreach ($qty as $quantity=>$value){
        $product .= $quantity.',';	
    }
    $produk2 = rtrim($product,',');
    $sql = "select * from test where idx in ($produk2)";
    ?>

how can i improve my sql query to inject qty(array value) in my result
thanks






