如何查看表元键值?

How do I view post value, table meta_key? I have to retrieve a value from a post that is in a meta_key in a table. I think that in order to import the correct meta_key values, I have to import the test_id which is the id, which is in the table. how do I do that? Thanks in advance. :)

 <?php
        global  $wpdb;
$id = get_the_ID(); // this only works with standard post loops
$option = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM wp_table_test WHERE meta_key = 'test_options' AND test_id = '%d'", $id));
echo "Meta key value for post ID $id: $option";
        ?>

Sorry bad english

There are at least two simpler options.

1) See https://developer.wordpress.org/reference/functions/get_post_meta/#comment-1894, one can just use $post->test_option,

or

2) is a dedicated wordpress function https://developer.wordpress.org/reference/functions/get_post_meta/. You say 'a post' so it sounds like you are looking for the value for the current post? possibly in post_template? This comment gives you examples og the various ways you might use it. https://developer.wordpress.org/reference/functions/get_post_meta/#comment-315