我的网站上有一张桌子,是住宅建筑商。他们在特定范围之间建造房屋,比如10万到70万美元。我正在尝试向那些正在寻找建造者的用户进行搜索,这些建造者在自己提交的范围内建造,比如$ 200,000到$ 250,000。有什么建议吗?我知道我可以使用BETWEEN搜索一个整数是否在一个范围之间,但我如何搜索一个范围内的范围?
例如:
SELECT post_id FROM wp_posts WHERE meta_price_range BETWEEN 200000 AND 300000
答案 0 :(得分:0)
这适合你吗?
select * from
( select 50000 as low, 250000 as high from dual ) client,
( select 100000 as low, 700000 as high from dual ) builder
where
client.high between builder.low and builder.high
or client.low between builder.low and builder.high ;
答案 1 :(得分:0)
SELECT post_id
FROM wp_posts
WHERE
(builder_price_range BETWEEN 200000 AND 700000)
AND
(buyer_price_range BETWEEN 400000 AND 500000)
显然填写参数会很有意思;需要更多关于如何处理的信息。