SQL JOIN Or any alternative

Hi. Does Grist support JOIN or have any other way to combine tables with different columns etc and select the data to keep? For example SQL has the JOIN, JOIN LEFT etc.

1 Like

Hi @Chris_Scott1! In Grist, Reference Columns and Linking Widgets take the role of JOINs in most cases.

For instance, in this example of SQL JOIN, a JOIN is used to include customer information into a query that lists orders. In Grist, each order would have a Reference to customer (rather than just an identifier for a customer), and including such joined information would be done with a formula column in the table of Orders, with a formula like $Customer.CustomerName or $Customer.Country.

If this isn’t what you need, maybe you could describe in more detail what you are trying to solve with JOINs?

(Aside: I should mention that support for raw SQL queries is something that’s been coming up recently in other contexts – e.g. here – but there aren’t firm plans yet for what Grist may offer and when.)

Hi Dmitry! Thanks for your answer. I’m not sure if that’s exactly what I need or not actually I don’t think so though. Here’s an example:

If I have Exports From 3 different marketing tools each with multiple different fields but share 3 common fields/keys, “URL, Domain, Traffic.”

I know that Grist now supports field mapping on import which could work in a somewhat similar way, but is there a way to merge these sheets with features similar to the different types of JOIN?

Also support for raw SQL queries is exciting. Are there any plans on integrating with BigQuery?

Ah, by this description, the SQL feature you seek is UNION rather than JOIN. It’s the same one as requested here: SQLite UNION operator.

Are you hoping to merge this data into a single table for viewing or calculations? Or do you envision making edits in this merged table as well?

Thank you. That may be correct and if so then the single table would be used primarily for viewing. Just to clarify though, I’d only want to merge the tables based on the keys with all of the other selected columns present, even if some cells are empty.