Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A null value in criteria[n] matches any field value  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI guys.

I�m a little confused with the requirements of the find() method, it says �Returns an array of record numbers that match the specified criteria. Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)�

It means that if there is a null value in the criteria all records will be return? Because a null value matches any field value:

Criteria = {�Fred�, null, null, null, null, null} returns all records because of the nulls or it just returns records that starts with �Fred�?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alejandro

I'm not sure it you have the same sun instructions as myself, but the following was a criteria for the UI....

It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user

So the only fields your are required to search on are name and location.

So if you have criteria{"Fred",null} then all contractors who name begins with fred in all location will be returned.

If you have criteria{null,"Smallville"} then all contractors in location smallville will be returned.

Hope this helps
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Alejandro,

I think the key is the assignement sentence "A null value in criteria[n] matches any field value". In my opinion, this statement stands for the
field[n] only. Having a null value at criteria[n] doesn't mean
the result is the whole database, it does just mean that there is no
filtering process to do on the records field[n].

Hope this help

Gilles
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!