This is the SQL:
UPDATE <YOUR_PREFIX_HERE>_posts SET post_content = replace(post_content, 'www.lol.com/?http://rapidshare.com', 'http://rapidshare.com');
Either inject it directly into the database (via PHPmyAdmin and the like) or use WordPress to do so.
Here's the WordPress way:
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"UPDATE <YOUR_PREFIX_HERE>_posts
SET post_content = replace(post_content, %s, %s)",
'www.lol.com/?http://rapidshare.com',
'http://rapidshare.com'
)
);
// EDIT
For completeness (as @birgire suggested): if you don't know the table prefix, you can let WordPress look that up:
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->posts}
SET post_content = replace(post_content, %s, %s)",
'www.lol.com/?http://rapidshare.com',
'http://rapidshare.com'
)
);