I know that:
$wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users;");
Can select wordpress user by mysql, but when I call a buddypress group, it failed, nothing returns
$wpdb->get_var("SELECT COUNT(*) FROM $wpdb->bp_groups;");
How do I fix this?
$wpdb only stores information on the Wordpress tables. Buddypress is going to be elsewhere.
The following page has a database map, with the default table names. Since the 'wp_' portion isn't certain you'll want to use $wpdb->prefix
http://api.buddypress.org/development/legacy-analysis/data-model-1-dot-3/
So either of the following should work fine
$table = $wpdb->prefix."bp_groups";
$wpdb->get_var("SELECT COUNT(*) FROM $table;");
or inline
$wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}bp_groups;");
You can use that schema map as a guide to getting more information, like how many users are in certain groups, etc...
Good luck :)