Prompt

Generate SQL from just table/column names

coding · works with Any model · via dair-ai/Prompt-Engineering-Guide

The prompt

Table departments, columns = [DepartmentId, DepartmentName]
Table students, columns = [DepartmentId, StudentId, StudentName]
Create a MySQL query for all students in the Computer Science Department

Expected result

A correct SQL query joining students to departments on DepartmentId and filtering DepartmentName = 'Computer Science'.

Why it works

Shows the minimum context a model needs for reliable SQL generation: just table names and column lists — no full schema DDL required, as long as the relationship between tables is inferable from shared column names.

Open in PrompVite to copy, rate, and discuss this prompt →