ああ、EAVの喜び。つまり、複数のサブクエリまたはクロス集計を実行する必要があります。
Select ...
From Posts
Where post_id In (
Select post_id
From Meta
Where Attribute = 'City'
And Value = 'Dallas'
)
And post_id In (
Select post_id
From Meta
Where Attribute = 'Style'
And Value = 'Ranch'
)
And post_id In (
Select post_id
From Meta
Where Attribute = 'Price'
And Cast(Value As int) Between 100000 And 200000
)
And post_id In (
Select post_id
From Meta
Where Attribute = 'Pool'
And Value = 'True'
)
ここでは、クロスタブを作成する別のフォームを示します。それはよりコンパクトですが、同様に動作しない可能性があります:
Select ...
From Posts As P
Join (
Select post_id
, Min(Case When Attribute = 'City' Then Value End) As City
, Min(Case When Attribute = 'Style' Then Value End) As Style
, Min(Case When Attribute = 'Price' Then Cast(Value As int) End) As Price
, Min(Case When Attribute = 'Pool' Then Value End) As Pool
From Meta
Where Attribute In('City','Style','Price','Pool')
Group By post_id
) As Attributes
On Attributes.post_id = P.post_id
Where Attributes.City = 'Dallas'
And Attributes.Style = 'Ranch'
And Attributes.Price Between 100000 And 200000
And Attributes.Pool = 'True'
ありがとう!私のために働く! –