SELECT wp_posts.* FROM wp_posts, wp_postmeta WHERE wp_posts.ID = wp_postmeta.post_id AND wp_posts.ID = AND wp_posts.post_status = 'publish' AND wp_posts.post_type = 'coursedates' AND wp_postmeta.meta_key = 'related_posts'