How to mysql query `$wpdb->get_var` `bp_groups` in buddypress?

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 return

$wpdb->get_var("SELECT COUNT(*) FROM $wpdb->bp_groups;");

Is there anyone know how to?

Only WP tables are referenced in the wpdb class. bp_groups is not a WP table so $wpdb->bp_groups doesn’t exist. Try this:

$wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}bp_groups;");

thanks, now I know the rule how to call a group query :}