How to show only child categories using the_category();

<?php
foreach((get_the_category()) as $category) {
    if ($category->category_parent  == '7') {
        echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf(__( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
    }
}
?>  

All you need to do is replace 7 with whatever category you want to include