Searching - "And" vs. "Or" FieldNamedatarq=value
- Matches multiple search criteria.
Sometimes you want to match one field and another field at the same time -- this if often called "anding fields together". Examples are "Find all people whose first name is Grant and last name is Hulbert" or perhaps "Find all houses that have more than 5 bedrooms and a fireplace and 2 bathrooms".
By default, if you do not specify certain fields are required to match, they are "or-ed" together, which in the above examples would read like "Find all people whose first name is Grant or last name is Hulbert" or perhaps "Find all houses that have more than 5 bedrooms or a fireplace or 2 bathrooms".
- Important: WebDNA automatically 'ranks' the best-match results to the top of the list of found items. In the "or-ed" example above, all the houses that have more than 5 bedrooms and a fireplace and 2 bathrooms are shown at the top of the list. Houses that match 2 out of the 3 criteria are listed just below those, and finally houses that only match one of the criteria are listed last. You can override this standard ranking by forcing a different sort order.
-
- Note: typically "and" will find fewer matches in a database, because it is more restrictive -- the chances of finding a house that matches all 3 criteria simultaneously is far lower than finding a house that matches any one of the criterion individually.
To require particular fields to match during a search, put the letters "rq" after the data specifier, as in the following examples:
FirstName is Grant and LastName is Hulbert |
eqFirstNamedatarq=Grant&eqLastNamedatarq=Hulbert |
Bedrooms > 5 and fireplace is True and Bathrooms is 2 |
gtBedsdatarq=5&eqFireplacedatarq=T&eqBathsdatarq=2 |
A complete URL for one of these searches might look like this:
http://Results.tpl?command=search&eqFirstNamedatarq=Grant&eqLastNamedatarq=Hulbert&db=People.db
- Note: You can make all fields required in one simple step by putting "AllReqd=T" into the search URL or form.
The Results.tpl file would contain a [FoundItems] loop that fills with all the matching records, and the resulting HTML would be sent back to the browser.
- Note: you can also embed a [Search] context in a template. Any browser accessing that HTML page (no special commands required - just link to the page) will see the 'live' search results. It might look like this:
-
- <BODY>
- Here's an embedded search:<br>
- [Search db=People.db&eqFirstNameDatarq=Grant&eqLastNamedatarq=Hulbert]
- [FoundItems]
- [FirstName], [Address], [City], [State], [Zip]<br>
- [/FoundItems]
- [/Search]
- </BODY>