sql - query using SOME in mysql not giving expected results.? -
suppose have table :
start_range end_range 1 4 4 8
i want result true if greater of value of start_range , less of corresponding end_range.
eg.
value 2 should homecoming true
, 2>1
, 2<4
value 4 should homecoming false
in case 4>1
4<4
becomes false, 4>4 becomes false sec case.
i cannot utilize query
select sumthing xyz value> some(start_range) , value < some(end_range)
the problem above query allow value = 4.
now 4> some(start_range) become true 4>1. and
4< some(end_range) become true 4<8.
but in actual comparing should (((4>1)and(4<4)) or ((4>4)and(4<8)))
. should homecoming false.
one more thing , above table not persistent , i have been creating in subquery.thats why have been using some. if still question isn't clear, mention in comments.
assuming xyz
table:
select (count(*) > 0) hasmatch xyz value > start_range , value < end_range;
i'm not sure why using some
.
edit:
it occurs me want utilize subqueries, , xyz
not table in question. perhaps want:
select xyz.* xyz exists (select 1 (<your query here>) t xyz.value > t.start_range , xyz.value < t.end_range );
mysql sql