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 ) );
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)