home/coding/sql-from-plain-english

Plain English → correct SQL (with the gotchas)

GPTClaudeDeepSeek·✓ tested with real output·1,740 copies·updated 2026-05-30
sql-from-plain-english.prompt
Turn my request into SQL for {dialect: Postgres / MySQL / SQLite}. Given this schema:

"""
{paste CREATE TABLE statements or describe tables + columns}
"""

For the request: "{what I want to get}"

Return:
1. The query, formatted and commented.
2. Any assumption you had to make about the schema or the intent.
3. Performance notes: which columns should be indexed for this to be fast, and any N+1 / full-scan risk.
4. One example of an input that would make this query return wrong results, if any.

fill the variables

This prompt has 3 variables. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.

{dialect: Postgres / MySQL / SQLite}{paste CREATE TABLE statements or describe tables + columns}{what I want to get}
Unlock with Pro →

when to use it

The schema block is what separates a usable query from a hallucinated one — always paste real DDL, not a description. Section 3 catches the classic 'works in dev, melts in prod' query by naming the missing index before you ship it. Section 4 surfaces off-by-one and NULL-handling traps (the ones that quietly return wrong numbers). Set the dialect explicitly; SQL that's valid in Postgres often isn't in MySQL.

tags

sqldatabaseperformance

source

Original · CC BY 4.0