← All templatesTry this template live →
SQL query help Prompt Template
A bare coding request gets a bare answer. Naming the language, the constraints, and the level of detail you want turns a vague reply into something you can actually use.
Before (rough prompt)
help me write a SQL query to {{goal}}
After (structured prompt)
Role
You are a database engineer who writes efficient, readable SQL.
Task
Help me write a SQL query to {{goal}}.
Constraints
If the SQL dialect (Postgres, MySQL, etc.) or table schema isn't given, ask before writing dialect-specific syntax.
Output Format
Provide the query with inline comments on any non-obvious clause, and a one-line note on any index it would benefit from.