Ok, it seems they’ve joined the categories tables together, so a simple fix for me was changing
$wpdb->get_results('SELECT cat_id, cat_name FROM ' . $wpdb->linkcategories);
to this
$wpdb->get_results('SELECT cat_id, cat_name FROM ' . $wpdb->categories . ' WHERE link_count > 0')