多选从wordpress sql

I tried to get posts from wordpress sql, I want get posts where post_type = 'post' and where post_type = 'page'

My code:

   $wpdb->get_row( " SELECT * FROM $wpdb->posts WHERE post_type = 'post' and post_type = 'page' AND post_status = 'publish' ORDER BY RAND() " );

This code is correct

$wpdb->get_row( " SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY RAND() " );

but only post_type = 'posts' i want both! post and page.

About Wordpress SQL

Thanks.

You can use OR:

$wpdb->get_row( " SELECT * FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND post_status = 'publish' ORDER BY RAND() " );

...but I still don't understand why you don't do a standard WP_Query().

$args = array(
    'post_type' => array('post', 'page'),
    'orderby' => 'rand',
    'posts_per_page' => -1
);
$query = new WP_Query( $args );