Select custom post by meta value

I think you mean a query like this one:

$args = array( 
               'post_type'      => 'foo', 
               'meta_key'       => 'bar', 
               'meta_value'     => 'pineapple',
               'posts_per_page' => 1,
        );

$query = new WP_Query( $args );

You can check out further information here on meta queries in WP_Query.

If you only want to check if there exists such a post, you can use the found_posts property:

if( $query->found_posts > 0 ){
    // do stuff
}

or the usual way with the have_posts() method:

if( $query->have_posts() ){
    // do stuff
}