wpdb php get_var query to get ID for URL image doesn’t work for ID over 999

wpdb php get_var query to get ID for URL image doesn’t work for ID over 999

tech