SQL Query Generator Prompt
Translate plain-English data requirements into optimized SQL queries, complete with performance tips and a clear explanation of the chosen approach.
The prompt
Write a SQL query for the following requirement. Include comments explaining any non-obvious parts. If there are multiple approaches, show the most performant one and briefly note the tradeoff:
{{requirement}}Works in ChatGPT, Claude, Gemini and other assistants. Replace the highlighted placeholders with your own content.
How to use it
Describe what data you need at {{requirement}}. Paste the relevant table definitions above the prompt so column names and joins are correct, and state your database (PostgreSQL, MySQL, SQLite).
Tips for better results
- Include table schemas. Without them the AI guesses column names.
- Ask for the query plan considerations if the tables are large.
- Run it on a copy or with LIMIT first, never straight on production.
Save this prompt in Promta
Keep it in your library and paste it from the menu bar, a hotkey or your iPhone keyboard, without leaving the app you're in.
Download Free on App Store
Free to start · iPhone & Mac