SQL query generator prompt from plain English

Turn a plain-language data request into a working SQL query, with clause-by-clause explanation and flagged assumptions.

بواسطة ‪Ahmed Eid‬‏GPT0 نسخة

متى تستخدم هذا البرومبت

  • When you know what data you need but not the exact SQL syntax.
  • When writing a report query against an unfamiliar schema.
  • When teaching SQL by comparing intent to query.

نص البرومبت

Write a {{language}} SQL query for the following request against this schema: {{focus}}. Explain each clause briefly and flag any assumptions about table or column names.

{{CLIPBOARD}}
{{language}}{{focus}}{{CLIPBOARD}}

الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».

كيف تستخدمه

  1. انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
  2. الصقه في ChatGPT أو Claude أو Gemini.
  3. عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.

مثال على النتيجة

SELECT c.name, SUM(o.total) AS lifetime_value
FROM customers c
JOIN orders o ON o.customer_id = c.id
WHERE o.status = 'completed'
GROUP BY c.name
ORDER BY lifetime_value DESC
LIMIT 10;

Assumption: 'orders.total' stores the order amount in the customer's currency.

نصائح للاستخدام

  • Paste your actual table and column names, or a CREATE TABLE statement, for accurate results.
  • Specify the SQL dialect (PostgreSQL, MySQL, SQLite) since functions differ.
  • Always review generated queries against production data before running them.

النماذج الموصى بها

GPT

أسئلة شائعة

Do I need to share my full database schema?
Only the relevant table and column names; you never need to share actual data, just structure.
Can it write queries with joins and subqueries?
Yes, describe the relationships in plain English and it will structure joins, subqueries, or CTEs as needed.

برومبتات ذات صلة

Generate a GraphQL Schema from a Description

Describe your data and operations in plain English and get a complete, documented GraphQL schema.

Design a GraphQL schema (types, queries, mutations) for: {{focus}}. Use {{language}} conventions and include field-level descriptions. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Generate Realistic Mock Data for Testing

Get realistic, varied mock data, including edge cases, matched to your schema, ready to seed a test database.

Generate {{focus}} realistic mock/test data records in {{language}} format for this schema or type, with varied and edge-case values. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Explain What This Legacy Code Actually Does

Paste unfamiliar or legacy code and get a plain-language walkthrough, with dead code and possible bugs flagged.

Walk through this {{language}} code line by line and explain what it does, in plain language. Flag anything that looks like dead code, a workaround, or a potential bug. {{CLIPBOARD}}

{{language}}{{CLIPBOARD}}

Generate a Dockerfile for Your App

Get a secure, optimized Dockerfile tailored to your language and framework, ready to build and run.

Write a production-ready Dockerfile for a {{language}} app using {{framework}}. Use multi-stage builds where useful, minimize image size, and run as a non-root user. Notes: {{focus}}. {{CLIPBOARD}}

{{language}}{{framework}}{{focus}}{{CLIPBOARD}}
المزيد في برمجة