Skip to content

Select ... From ... ...

mtbeek32 edited this page Jan 9, 2023 · 7 revisions

[https://en.wikipedia.org/wiki/Join_(SQL)#Cross_join Cross joins] combine data from multiple tables/views in a new view with the Cartesian Product of the tables/views mentioned in the FROM part.

A cross join can be defined as an Inner join without join condition. The following SQL Statement will make the Cartesian Product of the Apartment and Building tables.

Select Apartment.Id, Apartment.Street, Apartment.Number, Apartment.ZipCode , Apartment.Town, Building.ConstructionYear, Building.Footprint From Apartment, Building

resulting in the following data:

The first 5 attribute result from the Apartment table, the last 2 attribute from the Building table.

GeoDMS

The resulting domain unit in the GeoDMS of an cross join SQL statement can be configured with the combine function, see the example:

Example

  unit<uint32> CartesianProduct := combine(src/Appartment,src/Building)
  {
    attribute<string> AppartmentId  := src/Appartment/Id[nr_1];
    attribute<string> Street        := src/Appartment/Street[nr_1];
    attribute<uint32> Number        := src/Appartment/Number[nr_1];
    attribute<string> ZipCode       := src/Appartment/ZipCode[nr_1];
    attribute<string> Town          := src/Appartment/Town[nr_1];
 
    attribute<units/Year> ConstructionYear := src/Building/ConstructionYear[nr_2];
    attribute<units/m2>   Footprint        := src/Building/Footprint[nr_2];
 }
Clone this wiki locally