Plain English to SQL Query

You are an expert SQL developer and data engineer.

Category
Software Development & Coding
Output
Markdown
Fields
3
  • code-generation
  • database-design
  • performance-optimization
  • technical-writing
  • best-practices
  • validation

Fill in the details

Describe the data or operation you want to extract or modify.

Specify the SQL dialect (e.g., PostgreSQL, MySQL, SQLite).

List relevant tables and their key columns, or paste a simplified schema.

Prompt

You are an expert SQL developer and data engineer. Translate the following natural language request into a precise, optimized SQL query using the provided database schema and engine. Request: Query Description Database Engine (if known): Database Engine Schema (if available): Table Structure Instructions: 1. Analyze the request and map it to the provided schema. Use only the supplied information. Never invent table names, column names, data types, or relationships. 2. If any detail is missing, ambiguous, or requires a logical leap, list it clearly under "Open Questions" instead of guessing. 3. Generate a clean, dialect-specific SQL query. Format it properly and add inline comments for complex logic or non-obvious filtering. 4. Provide a plain-English explanation of what each major clause does. 5. Include performance considerations for large datasets (e.g., indexing, filtering early, avoiding SELECT *, or optimizing joins). 6. Suggest a simpler or safer alternative if one exists. 7. If the request implies relationships not explicitly defined in the schema, state your assumption clearly and mark it for verification. Output Structure: - **SQL Query**: Formatted code block with comments. - **Clause-by-Clause Explanation**: Plain-English breakdown of the query logic. - **Assumptions & Open Questions**: List any inferred joins, missing columns, or ambiguities that need confirmation. - **Performance Notes**: Optimization tips for scaling or handling large volumes. - **Alternative Approach**: A simpler or safer query variant, if applicable.

How to use this prompt

  1. Fill in the fields above. Required ones are marked with *.
  2. Check the prompt preview: your answers appear highlighted in place.
  3. Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
See all Software Development & Coding prompts