use mysql variable in a $wpdb->query to reindex a column?

If I correctly understood, this is not possible (two queries instead of one).
I ended up with this sad and time-consuming loop… :/

    //get subtracks
    $querystr = $wpdb->prepare("SELECT subtrack_id FROM `$subtracks_table` WHERE tracklist_id='%d' ORDER BY `subtrack_time` ASC",$this->post_id);
    if ( !$ids = $wpdb->get_col($querystr) ) return;

    //update order
    $i = 0;
    foreach($ids as $id){

        $i++;

        $wpdb->update( 
            $subtracks_table, //table
            array('subtrack_order'=>$i), //data
            array('subtrack_id'=>$id) //where
        );
    }