You can affect the content which is displayed from a database in two main ways:
- Filtering the database
- Ordering the database
Ordering the database
- Choose the field you want to order by.
- Select an ascending or descending ordering method (123/321)
- Random order: Allows us to show a different order on the data view every time we access it.
IMPORTANT: When ordering text fields (main ideas):
- Strings are compared character by character, i.e. first step all first characters, then all second characters.
- If there is no character, is "smaller", i.e. nothing is smaller than anything, therefore AA is smaller than AAA.
- Capital letters are "smaller" than small letters.
- Numbers are smaller than letters.
- Spaces are between numbers and letters
Here is a small example of text ordering:
When ordering by distance, the simulator on the web page doesn't work because the distance is relative to your phone. Therefore a mobile preview is required.
Obviously, multimedia fields cannot be ordered.
Filtering database
Filtering data works thanks to the conditionals and the operator. You can filter data using the following conditionals and operators:
- Conditionals
- AND
- OR
- Operators
- Equal
- Include
- Starts with
- Less than
- More than
Before displaying the data of a database, all the rows of the database table are scanned. Because we apply conditions to the values of each field in a database, only those values that pass the filter are displayed. For example:
When adding more than one filter, you are creating an "AND" condition. You are checking the database, showing only the registered rows that fit under the conditions created.
When adding "OR" conditions, only one of the conditions has to be fulfilled to accept a data. In the following picture, we show how to add "OR" conditions:
Maximum number of OR conditions are 5 and AND are 8.
On youtube: Filters and data bases