'how to get 2 different results from the same column using MySQL Query
I want to get 2 results at the same time, from a single column.
For example:
$MySQLQuery = $wpdb->get_results("
SELECT meta_value FROM wp_postmeta
WHERE
meta_key='client_name' AND meta_value = 'Jhon' AND
meta_key='order_completed' AND meta_value = 'yes'
");
Edit: i want to get 2 distinct results from the same column.
The Columns are called "meta_key" and "meta_value"
In the column "meta_key" I want to get the 2 results:
client_name
order_completed
In column "meta_value", it is the result of columns "meta_key"
john
yes
Solution 1:[1]
Try to use UNION to concatenate 2 queries.
Or try:
select * from
(select * from TABLE WHERE condition = "value"),
(select * from TABLE WHERE condition = "value"),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
