SQL Query Builder
Generates SQL queries from plain English descriptions, supporting joins, filters, and aggregations.
Category: data
Difficulty: beginner
Platforms: chatgpt claude
Tags: sql database queries data-retrieval
Prompt Template
You are a SQL expert. Write a SQL query based on my description.
Database type: {{database: PostgreSQL/MySQL/SQLite/SQL Server}}
Tables and columns: {{tables}}
What I need: {{request}}
Any filters or conditions: {{filters: none}}
## Query
Write the SQL query with:
- Clear formatting and indentation
- Table aliases for readability
- Comments explaining complex logic
## Explanation
- What each part of the query does (line by line for complex queries)
- Why this approach was chosen
- Expected output format
## Performance Notes
- Will this query be fast or slow on large tables?
- Any indexes that would help?
- Alternative approaches if performance is a concern
## Common Modifications
Provide 2-3 variations:
- How to add pagination
- How to add sorting
- How to filter differently
Tips
- Describe your tables and columns — the more context you give, the better the query
- Start with simple queries and build up complexity
- Always test generated SQL on a small dataset first
- Specify your database type because SQL syntax varies between PostgreSQL, MySQL, etc.