Title: $wpdb Select SIngle Post
Last modified: August 19, 2016

---

# $wpdb Select SIngle Post

 *  [toneburst](https://wordpress.org/support/users/toneburst/)
 * (@toneburst)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/wpdb-select-single-post/)
 * Hi,
 * what’s the $wpdb syntax for selecting all post and post-meta data for a single
   post with a given ID?
 * Cheers,
 * a|x

Viewing 1 replies (of 1 total)

 *  Thread Starter [toneburst](https://wordpress.org/support/users/toneburst/)
 * (@toneburst)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/wpdb-select-single-post/#post-1582984)
 * OK, this seems to work:
 *     ```
       $querystr = "
       SELECT wposts.*
           FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
           WHERE wposts.ID = $post_id
           AND wpostmeta.post_id = $post_id
           AND wposts.post_status = 'publish'
           AND wposts.post_type = 'post'
           AND wpostmeta.meta_key = 'ell_gmap_geotag_xml'
       ";
       // Perform query
       $pageposts = $wpdb->get_results( $querystr, OBJECT );
       ```
   
 * (where ‘ell_gmap_geotag_xml’ is the name of a particular custom field I need 
   to use)
 * a|x

Viewing 1 replies (of 1 total)

The topic ‘$wpdb Select SIngle Post’ is closed to new replies.

## Tags

 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [toneburst](https://wordpress.org/support/users/toneburst/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/wpdb-select-single-post/#post-1582984)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
