Viết và tối ưu truy vấn SQL
A ready-to-use “Lập trình” AI prompt template, designed and tested with ChatGPT. Replace the (bracketed) parts below with your own needs.
Prompt template
Bạn là kỹ sư cơ sở dữ liệu. Hãy viết một truy vấn SQL đúng theo yêu cầu bên dưới, giải thích mục đích của mỗi JOIN và điều kiện, và cuối cùng đưa ra gợi ý tối ưu hiệu năng (index, tránh quét toàn bảng, v.v.). Cơ sở dữ liệu: (ví dụ: MySQL/PostgreSQL). Lược đồ bảng: (dán lược đồ). Điều tôi muốn truy vấn: (mô tả nhu cầu).
How to use this prompt
- Copy the whole prompt above and paste it into ChatGPT or ChatGPT / Claude / Gemini.
- Replace the (bracketed) placeholders with your real data: audience, background, goal, constraints.
- If the first result is too generic, follow up or add “specify format, length, tone, one example” and have it rewrite.
Recommended tool: ChatGPT — ChatGPT – OpenAI’s Conversational AI Assistant