ChatGPT prompt to write an SQL query
Describe your tables and ask your question in plain English: the AI writes the SQL query for your database, explains it and flags the pitfalls.
Your prompt
🔒 The fields stay in your browser. The prompt is only sent to the AI service you choose to open.
How do I write an SQL query with ChatGPT?
Ask your question in plain English, state your database (MySQL, PostgreSQL…) and paste the structure of the relevant tables. Ask for a readable query explained clause by clause, with no invented columns. The Lunyce prompt prepares this request; test the query on a copy before changing any data.
How to use it
- Ask your question in plain English and state your database (MySQL, PostgreSQL, SQL Server, SQLite…).
- Paste the table structure: names and columns are enough, no need for the data.
- Copy or open the prompt, then test the query on a copy or with a row limit.
Tips for better results
- Paste only the table structure, never real customer data.
- To get the structure, use SHOW CREATE TABLE (MySQL) or \d table_name (PostgreSQL).
- Test any UPDATE or DELETE query on a copy of the database, after a backup.
Do I need to know SQL to use this prompt?
No: ask your question in plain English and describe your tables. The AI writes and explains the query. Still check the result on a few rows you know.