I have a woocommerce DB
Products are stored in rows where each row has:
post_id (int not unique)
meta_key (varchar)
meta_value (double)
I am trying to find all post_id where the value of meta_key which equals to "_price" is different from the value of meta_key which equals to "_sale_price".
This is what I tried which of course didnt work
SELECT * FROM `yai_postmeta`
where meta_key = "_price" <> meta_key = "_sale_price"
2
Answers
Maybe this is what you mean?
show records where the _sale_price is different than the _price of the same post_ID. I assume the absence of a corresponding record is different. or if both values are null that’s "different"
If you only want the
post_id
values then this might be what you are looking for:Runnable, with extended sample data (dbfiddle):