Title: Missing Argument 2 For WPDB
Last modified: August 31, 2016

---

# Missing Argument 2 For WPDB

 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/missing-argument-2-for-wpdb-6/)
 * I am trying to run the below query and output but getting the error as seen below.
   I get you should add an argument but with a query that really doesnt have one
   what do you do?
 * Just trying to get all email addresses from comments and display them.
 *     ```
       $myrows = $wpdb->get_results( $wpdb->prepare("SELECT DISTINCT comment_author_email FROM wp_comments" ));
       foreach ( $myrows as $myrows )
       {
       	echo $myrows->comment_author_email;
       }
       ```
   
 * `Warning: Missing argument 2 for wpdb::prepare()`
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/missing-argument-2-for-wpdb-6/#post-6920990)
 * You don’t really need `prepare()` unless variables are involved. All `prepare()`
   really does is escape the variable values. FYI, `prepare()` must be used like`
   sprintf()` – The SQL string with %s and %d placeholders first, followed by the
   variables to substitute for the placeholders.

Viewing 1 replies (of 1 total)

The topic ‘Missing Argument 2 For WPDB’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/missing-argument-2-for-wpdb-6/#post-6920990)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
