SELECT meta_value
FROM wp_postmeta
WHERE meta_key = "bid_resource_lat"
AND meta_key = "bid_resource_lng"
上記のように、1 つのクエリ内で 2 つの行を選択しようとしています...そして、これが機能しない理由を理解することはできません...
また、2 つの結果が 1 つの行にグループ化されていることを確認するにはどうすればよいでしょうか?
You need "OR" as the logic is the wrong way round from as you're imagining it.
SELECT meta_value FROM wp_postmetaWHERE meta_key = "bid_resource_lat" OR meta_key = "bid_resource_lng"
Explanation:
You want to get a row if the key is either the first OR if it's the second. This returns up to two rows. The way you wrote it then both conditions needed to be matched.
"I want a car that is italian OR expensive" - You can get a Ferrari, a Mercedes and a Fiat "I want a car that is italian AND expensive" - You can get a Ferrari
You want to use an OR
condition, not an AND
condition:
SELECT meta_value
FROM wp_postmeta
WHERE meta_key = "bid_resource_lat"
OR meta_key = "bid_resource_lng"
Your query could not return any rows, because you're asking for records where the meta_key
column is equal to both "bid_resource_lng"
and "bid_resource_lng"
, which can obviously never happen since one row will only have one value in the meta_key
column.
meta_key = "bid_resource_lat" AND meta_key = "bid_resource_lng"
上記は決して真ではありません。代わりに OR を使用してください。meta_key は、bid_resource_lat と bid_resource_lng を同時に指定することはできません。