Title: Help with SQL query
Last modified: January 21, 2017

---

# Help with SQL query

 *  Resolved [sethbahookey](https://wordpress.org/support/users/sethbahookey/)
 * (@sethbahookey)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/help-with-sql-query-2/)
 * Hi Team,
 * I’m looking to pull some data with SQL, but I believe I need to create a sub 
   query in order to achieve what I’m looking for.
 * I’m using the tables wp_postmeta and wp_posts. In postmeta I have SKUs listed
   in for each of my products, and I’m looking to create a spreadsheet in my site
   that has the ‘add to cart’ button for each product.
 * In order to to that I will need to align the SKUs with their respective IDs which
   is found in the table wp_posts.
 * So I’ve been trying to nest queries to pull the ID column from wp_posts and the
   SKU column(or rather the meta_value column) then that way I can line them up 
   and then use excel to create a CSV and import.
 * Can someone please help me on how to design this query. I only know SQL well 
   enough to get a few things done, but this nested stuff is a whole new level.
 * Thanks!!

Viewing 1 replies (of 1 total)

 *  Thread Starter [sethbahookey](https://wordpress.org/support/users/sethbahookey/)
 * (@sethbahookey)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/help-with-sql-query-2/#post-8682110)
 * … both pieces of info were in the same table!! nevermind. sorry about that

Viewing 1 replies (of 1 total)

The topic ‘Help with SQL query’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [sethbahookey](https://wordpress.org/support/users/sethbahookey/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/help-with-sql-query-2/#post-8682110)
 * Status: resolved