Types of Join
Left outer, inner and cross joins
Without any joins, you can only add fields, filters and calculations (display data in other words), from a view’s parent table - the one it was created from. When joins are added to other tables or views, you can also bring in data from any table or view joined to.
For example, a view based on the contacts table could join to organisations (as long as there is a relation field from contacts to organisations). You could then add in organisation name to the view, as well as fields like contact name, phone number and email address.
Or for a more complex example, if you start with a view from a recipes table, you could potentially join down to ingredients, then on again to allergens of those ingredients, allowing you to work out with a calculation the complete list of allergens in any recipe.
Any number of joins to different tables or views can be added to a view.
Agilebase will automatically pick out the common tables you may wish to join to, by seeing which are related via relation fields. Once you get used to the concepts, you may also wish sometimes to add joins manually to tables or views not automatically suggested. That will be covered at the end of this page.
To add a join
The added join will appear graphically above the Add Join button. The lefthand ‘blob’ or part represents the table being joined from, on the right is the one joined to. In the middle is a selector for the join type, which we will come to.
In each part, left or right, the name of the table being joined from (on the left) or to (on the right) is shown in bold.
Underneath the table name, the name of the field used to match records is shown. When an ID field is shown, this just refers to the internal ID Agilebase uses automatically to make the match. It’s only of relevance if you’re creating advanced joins manually - see below, so can be ignored otherwise.
In this example, we have a join from the contacts table to companies, to allow us to add company information into our view. The link was made based on the organisation field in the contacts table, which lets a company be assigned to a contact.
You may notice when clicking Add Join and looking at the list of potential joins available, that some of them show as joining up and others down.
Joins up are from a ‘child’ to a ‘parent’, i.e. you can think of a contact as belonging to a organisation, so a join from contacts to organisations is an upwards join. The other way round, it would be a downwards join.
What difference does this make? Well if you join down, then the view will contain one row for every child record, with repetitions in the parent data if the parent is the same. This is easier to see with a picture - here’s what a view from an organisations table looks like when it joins down to contacts - there are three contacts for the organisation TODO.
** TODO: screenshot **
However, joins down can be very useful when you want to aggregate child data, for example if you want to count the number of contacts each organisation has, you could add a join from organisations down to contacts, then add an aggregate calculation to count the contacts. The system would then condense everything into one row per organisation, like so:
** TODO: screenshot **
So joins upwards are the more common case, but joins downward can be useful for particular purposes.
As above, Agilebase automatically suggests joins to data that’s related to the current view’s parent table as well as any of the tables already joined to. It uses relation fields to see what’s related.
However, sometimes you may want to join to a table or view that’s not automatically suggested. These examples may become increasingly ’niche’ but they are a useful reference for similar situations you may come across.
Joins to views aren’t automatically suggested, but you can still add them.
When might this be useful? Well one example is if you have a view containing a complex calculation and you wish to include the results of that calculation in lots of other views in different places.
Say you calculate various nutritional values of a recipe, such as the energy, salt and fats contents. You may wish to display that information in a few views for different people to query, as well as include them in product specification documents (which can be generated from a workflow view) and perhaps product labels as well, using a view to send data to third party labelling equipment using an API.
To add a join to a view:
The last step is the only one different to the normal join addition process, and the one that needs a little explanation
To take the example above of the nutritional calculations, assume we have a view called ’nutritional values’, built from a ‘recipes’ table. To include nutritional data in another view ‘recipe details’, also built from the recipes table, we would edit recipe details and add a join as follows:
On occasion, you may wish to join to another table on data that is present in this and the other.
For an example, imagine our business opens a series of restaurants - we have a table ‘restaurants’ listing them. We may have a table of people who’ve signed up to our newsletter, called ’newsletter signups’. Some of them may have provided a postcode.
To find a list of people in the same postcode areas as each restaurant (the first half of a postcode, e.g. BS1):
You’ll then be able to add the name of the restaurant(s) in each signup’s area to the view. This could be to send them a special offer for their local restaurant for example.
As you can see, this also demonstrates creating a join on a calculation.
When you make a join on a field or calculation that isn’t an ID, be careful to ensure that the data is exactly the same on both sides. In this example, the postcode fields on both sides must be the same case (e.g. uppercase). Otherwise they won’t be picked up in the match.
Extending ‘creating a join on a calculation’ from the above example, here we can use a calculation to create a composite field to join on. This can be used when you want to join on a number of fields at once, not just one.
This can sometimes be useful in financial reporting. Our example here is creating a report totalling up sales by product by month. The twist is we also want to include product/month combinations in which there were no sales of a particular product for the month.
We’d start by creating a view of all product/month combinations over the past 12 months. See the series generation example in the calculations section for how to do this.
We’d then create a calculation ‘product month’ which would merge the product code and the month name. A similar calculation would be created in a ‘sales’ view, which shows individual sale lines, each with a product and month.
Finally, we’d join the two views together, the product/month combinations on the left, the sales view on the right, choosing the ‘product month’ calculations from each as the fields to match on.
That would enable us to create a calculation totalling sales for each product/month, including zeros where there were no sales.
Before removing a join, you first need to remove any uses of the joined object (table or view) from the view. To do that
If you still can’t remove a join, it may be that a field from the joined object is referenced elsewhere in the view setup - you can check other view panels like ‘properties and options’ or the ‘workflow’ panels.
Left outer, inner and cross joins
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.