Skip to content

DirectoryPrompts

Claude Opus 5.5

Write SQL from a Question – SQL query prompt for ChatGPT and Claude

Freewith a Recaply account
  • Free with an account
  • Copy filled in or download
  • Updates included
votes views

Claude Opus 5.5

This prompt turns a plain question into SQL. Paste your database type, the schema and your question; you get the definitions it used, the query, how it works and quick checks on the result.

What you get

  • The exact rule it used for each vague word, such as last 90 days or customer
  • One read-only query for your database, with comments on the joins and filters
  • A plain explanation of how the query works, in the order it runs
  • Quick checks to confirm the numbers before you use them

How to use it

  1. 1
    Paste the schema

    Copy the CREATE TABLE statements or a list of columns, and add what status or type values mean.

  2. 2
    Ask as you would ask a colleague

    Include what to leave out, how to sort and the time range, in plain words.

  3. 3
    Run the checks first

    Read the definitions, run the check queries, and only then use the numbers in a report.

Better results

  • Add a few sample rows when values are messy, such as mixed status spellings, so the filters match the real data.
  • If a definition is wrong, correct it in one line, such as "active means logged in within 30 days", and ask for the query again.
  • Run a new query on a replica, or with a LIMIT, before you run it on large production tables.

Questions

Can ChatGPT write SQL queries?

Yes, ChatGPT writes good SQL when you paste the schema and name your database, such as PostgreSQL or MySQL. Without the schema it guesses table and column names, so always give it the real ones and check the joins.

How do I turn a question into SQL with AI?

Paste the schema, name your database and ask the question in plain words, including filters and the time range. Ask the AI to state how it defined vague words like active or revenue, then run a quick check before you trust the numbers.

Is AI-generated SQL safe to run?

AI-generated SQL is safe to run when it is a read-only SELECT and you have read it first. Ask for read-only queries, check any UPDATE or DELETE line by line before running it, and test heavy queries on a copy or replica.

Updated 6 Oct 2026

Reviews

No reviews yet
Reviews open soonThey will come only from signed-in people who used this prompt.

Similar prompts

More coding prompts

Image prompts

Video prompts

Trending prompts

Newest prompts

Browse all prompts