Title: Convert Query object into Sql formate
Last modified: September 1, 2016

---

# Convert Query object into Sql formate

 *  [janothemes](https://wordpress.org/support/users/janothemes/)
 * (@janothemes)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/convert-query-object-into-sql-formate/)
 * I want to get the main Query in SQL formate before executing. So i can convert
   the object into Query?
 * my code is below.
 *     ```
       add_action('pre_get_posts','wpse50761_alter_query');
       function wpse50761_alter_query($query){
       	if ( !$query->is_main_query() )
       		return;
   
            // Now here $query contains the object
           i want it to convert into SQL formate.
        }
       ```
   

The topic ‘Convert Query object into Sql formate’ is closed to new replies.

## Tags

 * [pre_get_posts](https://wordpress.org/support/topic-tag/pre_get_posts/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 0 replies
 * 1 participant
 * Last reply from: [janothemes](https://wordpress.org/support/users/janothemes/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/convert-query-object-into-sql-formate/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
