The second example on this page has hardcoded table prefixes: http://www.gravityhelp.com/documentation/hooks-and-filters/
This could easily confuse someone less familiar with SQL / hacking wordpress.
Below is an example that will work with any table prefix, not just "wp_"
add_action("gform_post_submission", "post_submission_handler");
function post_submission_handler($entry){
global $wpdb;
$t_rg_lead = $wpdb->prefix . "rg_lead";
$t_rg_lead_detail = $wpdb->prefix . "rg_lead_detail";
$results = $wpdb->get_results($wpdb->prepare(" SELECT l.*, field_number, value
FROM $t_rg_lead l
INNER JOIN $t_rg_lead_detail ld ON l.id = ld.lead_id
WHERE l.id=%d
ORDER BY l.id, field_number", $entry["id"]));
foreach($results as $result){
echo "<hr/>Entry Id: " . $result->id . "<br/>";
echo "Field Number: " . $result->field_number . "<br/>";
echo "Field Value: " . $result->value . "<br/>";
}
}