In addition to looking at a table's column, you can also look at its connections if your table includes any. Connections show up here if there’s a column in the table you’re looking at that’s included in another table (i.e., a foreign key relationship). Click on **Connections** (located next to the **Fields** button) to view the connected tables.
### Foreign keys
You can find a list of connections to other tables (i.e., [foreign key](/glossary/foreign_key) relationships) under **Connected to these tables**. If there’s a column in the table you’re looking at that’s included in another table, Metabase will display this section in the sidebar. Note that connections are managed by your Metabase admin. If a foreign key relationship exists in your database, but not in your Metabase, your Metabase admin will need to update your [Metabase data model](../administration-guide/03-metadata-editing.md).
@@ -30,7 +30,9 @@ Don't worry if you don't understand this just yet. Click the blue **Run query**
You'll notice that the table that comes back is the same as if you had used the [query builder][asking-questions] to ask for the sum of `Subtotal` in the `Orders` table, grouped by the `Created At` date.
**Tip:** You can run your SQL query by pressing **ctrl + enter** on Windows and Linux, or **⌘ + return** on a Mac. You can also run only part of a query by highlighting the part you'd like to run before clicking the run button or using the run shortcut key.
### Running query selections
You can run your SQL query by pressing **ctrl + enter** on Windows and Linux, or **⌘ + return** on a Mac. You can also run only part of a query by highlighting the part you'd like to run before clicking the run button or using the run shortcut key.
Questions asked using SQL can be saved, downloaded, converted to models, and added to dashboards just like questions asked using the query builder.
...
...
@@ -52,6 +54,12 @@ You can use [SQL snippets](sql-snippets.md) to save, reuse, and share SQL code a
When you run a query from the SQL editor, Metabase sends the query to your database exactly as it is written. Any results or errors displayed in Metabase are the same as the results or errors that you would get if you ran the query directly against your database. If the SQL syntax of your query doesn’t match the SQL dialect used by your database, your database won’t be able to run the query.
## How Metabase executes SQL variables
When your query includes a SQL variable, the `{% raw %}{{#5}}{% endraw %}` tag will be substituted with the SQL query of the referenced question or model, surrounded by parentheses.
For an example, see the documentation on [Referencing models and saved questions in SQL queries](../users-guide/referencing-saved-questions-in-queries.html).
## Learn more
-[Best practices for writing SQL queries](https://www.metabase.com/learn/sql-questions/sql-best-practices.html)