You could use for example something like this:
RewriteRule ^(.*)/ show.php?id=$1
and:
$id = $_GET["id"];
.....mysql..
if (!$page_not_found) {
header('This is not the page you are looking for', true, 404);
include('your_404_page.php');
exit();
}