Get published posts and pages?

Don’t use pure SQL if you don’t have to. WordPress provides a useful and relatively solid class for retrieving post data. Use it.

$args = array(
  'post_type' => array('post','page'),
  'post_status' => 'publish',
  'posts_per_page' => -1,
  'ignore_sticky_posts' => true,
);
$qry = new WP_Query($args);
// Show post titles
foreach ($qry->posts as $p) { 
    echo $p->post_title; 
}

Reference:
http://codex.wordpress.org/Class_Reference/WP_Query