Get data from database using $WPDB

It may be because group doesn’t exist in the postmeta table. Your meta_key is probably called group and has a meta_value of bicyclegroup. This is assuming you haven’t modified the postmeta table. What you could try is:

$sql = "SELECT * FROM $wpdb->postmeta WHERE meta_key = 'group' AND meta_value="$group"";

This will return:

  • meta_id
  • post_id
  • meta_key ( group )
  • meta_value ( bicyclegroup )

Another option is to get all posts by post meta is a secondary query WP_Query. To do so would look like this:

$test_posts = new WP_Query( array(
    'post_type'      => 'post',
    'posts_per_page' => -1,
    'meta_key'       => 'group',
    'meta_value'     => $group
) );

<?php if( $test_posts->have_posts() ) : ?>

    <?php while( $test_posts->have_posts() ) : $test_posts->the_post(); ?>

        <h1><?php the_title(); ?></h1>
        <?php the_content(); ?>

    <?php endwhile; ?>

<?php endif; ?>

I’m not sure if you’re using post are your post type so change that field accordingly.