---
name: sql-join-helper
description: "Figure out exactly which SQL JOIN to use and generate the query. Use when the user wants help with SQL JOIN Helper. Related topics: sql, data, coding."
---

# SQL JOIN Helper

Figure out exactly which SQL JOIN to use and generate the query.

## How to use this skill

1. Ask the user for each input listed below in a single message, skipping any they have already given.
2. Where options are listed, offer them, but accept other answers too.
3. Fill the answers into the prompt template, then follow the completed prompt to produce the result.

## Inputs

- **Table 1 Name** (free text, e.g. "")
- **Table 2 Name** (free text, e.g. "")
- **What do they share? (Foreign Key)** (free text, e.g. "")
- **What data do you want?** (choose one: ALL records from both (Full Outer), Only matching records (Inner), All from Table 1 (Left), All from Table 2 (Right))
- **Additional filtering (WHERE clause)** (longer free text)
- **Database Engine** (choose one: PostgreSQL, MySQL, SQL Server)

## Prompt template

## Introduction
Generate correct SQL JOIN statements to combine your database tables.

## Table Details
- Table 1 Name: {{Table 1 Name}}
- Table 2 Name: {{Table 2 Name}}
- What do they share? (Foreign Key): {{What do they share? (Foreign Key)}}

## Desired Outcome
- What data do you want?: {{What data do you want?}}
- Additional filtering (WHERE clause): {{Additional filtering (WHERE clause)}}
- Database Engine: {{Database Engine}}

---
**Goal**: Output the precise SQL query and explain how the chosen JOIN works.

---

Source: [SQL JOIN Helper on PromptBuild](https://promptbuild.io/prompt/j1N3hTP9HdWXLVK7r5m8/sql-join-helper)
