[英]How to find record which falls inbetween two fields in mysql?
i have two fields in a table jobpost like this:- 我在表作业中有两个字段,例如:
jp_id jp_min jp_max 1 0 1 2 1 2 3 3 4 4 4 8 5 2 3 6 0 1What i'm trying to find out is if i search for a job with experience 5-9 or 1-5 i should get 4rth record. 我想找出的是,如果我找工作经验为5-9或1-5的工作,我应该获得4rth记录。 But if i search for 1-3 exp then i shouldn't get the 4rth record. 但是,如果我搜索1-3 exp,那么我就不会获得第4条记录。
a)SELECT * FROM jobpost WHERE jp_min >=1 AND jp_max <=5; a)从工作岗位中选择* jp_min> = 1且jp_max <= 5; & 和\nb)SELECT * FROM jobpost WHERE (jp_min >=1 AND jp_max <=5); b)SELECT * FROM Jobpost WHERE(jp_min> = 1 AND jp_max <= 5); (this one gives result of (这给出了 \njobpost which requires 1-5 exp only and not that 4rth record 4-8 exp.) 只需要1-5 exp而不是第4个记录4-8 exp的职位)。but it's not giving me the desired results. 但这并没有给我想要的结果。 Can someone give me hint or so. 有人可以给我提示。
When searching for an experience range of a
- b
, the following query should do the trick:- 当搜索a
- b
的体验范围时,以下查询应该可以解决问题:-
SELECT * FROM jobpost WHERE
(a>=jp_min AND a <= jp_max) OR (b>=jp_min AND b<=jp_max) ;
这是你想要的吗?:-
SELECT * FROM jobpost WHERE (jp_min BETWEEN '1' AND '5') OR (jp_max BETWEEN '1' AND '5') OR (jp_min < '1' AND jp_max > '5');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.