MySQL Forums
Forum List  »  Newbie

Re: reading database
Posted by: Barry Galbraith
Date: May 18, 2024 05:15PM

You want to return 1 row?

Without seeing the table structure, I can't see how 1 column "meta_key" can have 2 values "_billing_collection_date" and "_billing_collection_time".

If you mean you want two rows, what connects those 2 rows together?

It sounds like you have got EAV (Entity, Atribute, Value). Such a structure is not a good way to store data in Relational Database.

You can get one of your rows like this.
SELECT order_id
FROM pxyv_wc_orders_meta
WHERE meta_key = "_billing_collection_date" 
AND meta_value = "08/04/2024";

The same can be done to retrieve meta_key = "_billing_collection_time"

As a sidenote. It looks like you have date stored as a string in a varchar. You almost always should store dates in a DATE type.

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
May 18, 2024 12:39PM
Re: reading database
May 18, 2024 05:15PM
June 10, 2024 01:41PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.