Title: getting data from database
Last modified: May 18, 2024

---

# getting data from database

 *  [Steve2106](https://wordpress.org/support/users/steve2106/)
 * (@steve2106)
 * [2 years ago](https://wordpress.org/support/topic/getting-data-from-database/)
 * Trying to select from database based on meta_keys and meta_values. Tried this
   code below but I need it to only show the data from “08/04/2024” & “Morning 08:
   00 – 12:00”
 * SELECT DISTINCT
   t1.id,t1.meta_value AS DatePicked,t2.meta_value AS TimePickedFROMpxyv_wc_orders_meta
   t1JOIN pxyv_wc_orders_meta t2 ON t1.order_id = t2.order_idWHEREt1.meta_key = ‘
   _billing_collection_date’AND t2.meta_key = ‘_billing_collection_time’

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Steve2106](https://wordpress.org/support/users/steve2106/)
 * (@steve2106)
 * [2 years ago](https://wordpress.org/support/topic/getting-data-from-database/#post-17764847)
 * I need to set the meta_values to 08/04/2024 & Morning 08:00 – 12:00 respectively.
   
   So I can select only on those values.How would I do that?Thank you.
    -  This reply was modified 2 years ago by [Steve2106](https://wordpress.org/support/users/steve2106/).
 *  [Sebastien SERRE](https://wordpress.org/support/users/sebastienserre/)
 * (@sebastienserre)
 * [2 years ago](https://wordpress.org/support/topic/getting-data-from-database/#post-17765274)
 * Hello,
 * On native WordPress post, I would say you to use [https://developer.wordpress.org/reference/functions/get_post_meta/](https://developer.wordpress.org/reference/functions/get_post_meta/)
   but it seems you’re working on WooCommerce orders and since they use different
   tables from WordPress ones, I would say this would be better to use WooCommerce
   functions to retrieve data : [https://www.businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/](https://www.businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/)
 * In a general way, we avoid to use direct SQL query because it bypasses the environment
   and you may lose data from a third party plugins or theme. In case you really
   need, then use [https://developer.wordpress.org/reference/classes/wpdb/](https://developer.wordpress.org/reference/classes/wpdb/)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘getting data from database’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Sebastien SERRE](https://wordpress.org/support/users/sebastienserre/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/getting-data-from-database/#post-17765274)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
