How to properly check if a table exists in WordPress Database using Show Tables Query

This code is working for me with no “WordPress database error” messages:

if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) === $table_name ) {
    error_log( 'Table exists' . ': ' . print_r( $table_name, true ) );
} else {
    error_log( 'Table does not exist' . ': ' . print_r( $table_name, true ) );
}