Viết một truy vấn cơ sở dữ liệu (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
Hãy viết SQL: 1) một truy vấn theo nhu cầu tôi mô tả; 2) giải thích từng phần nó làm gì; 3) chỉ ra các vấn đề hiệu năng khả dĩ (thiếu chỉ mục, quét toàn bảng) và cách sửa; 4) nhắc tôi các trường hợp biên (NULL, trùng lặp, múi giờ).

Cấu trúc bảng: "mô tả các bảng và cột"
Điều tôi muốn truy vấn: "mô tả nhu cầu"

How to use this prompt

  1. Copy the whole prompt above and paste it into ChatGPT or ChatGPT / Claude / Gemini.
  2. Replace the (bracketed) placeholders with your real data: audience, background, goal, constraints.
  3. 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