I am trying to get all documents whose last name less than or equal to C. But it does not bring data starting with “C”.
db.sar.find({“Last_Name”:{$lte:“C”}})
{ “_id” : 6, “Last_Name” : “Brady”, “First_Name” : “Eoin”}
It does not return documents with “C” as last name why?
It works fine with $gte.
db.sar.find({“Last_Name”:{$gte:“C”}})
it brings last name starting with C and others.
Thanks in advance
Sarma
My question is that why it does not bring data when I say $lte : “C”. (less than or equal to C). I am expecting it to bring data for C as well. This works for numeric data but it is not working for string data.
Any thoughts on this please?
Look at the output of my sort above. The name Ci comes after C so it is bigger. And think about it, $lte CANNOT select the same set than $gte EXCEPT for the one that are equals.
Please show me a number that is both $gte and $lte to another one but that is not equal.
No you do. But you do not understand my answer. Look back at my sorted output. The string Ci, or any string that starts with C, comes after C so they are $gte. Since they are not equal they are $gt.
Yes. But if Ci, as in my example above, is $gte to C, and then since it is not equal to C, then is not less than equal.