SQL
To turn a written request into a query, pick out three things: the fields to show, the table to search and the condition the records must meet. Imagine a table TblBooks holding BookID, BookName, Author, Copies and Shelf. A request for “the name and shelf of books with more than 4 copies” needs BookName and Shelf, from TblBooks, where Copies is greater than 4.
Write SELECT first, then your field names separated by commas — never by AND. Next write FROM and the exact table name. Last, write WHERE and the condition, using a single = for equality and quotation marks around text values, such as "Priya Raman". Numbers do not need quotes.
Put the * wildcard after SELECT only when the request asks for all fields or all details; when it names particular fields, list just those. Leave WHERE out when the request wants every record, because a query with no condition returns them all — adding an invented condition quietly drops rows you were asked for.
Each part of a statement earns its own mark, so keep the parts that are already right and change only what is wrong. Check one fault at a time: the clause keyword, the field list, the table name, the operator and the quotation marks around text.
| Part of the query | Wrong | Right |
|---|---|---|
| Clause keyword | IF | WHERE |
| Field list | BookName AND Author | BookName, Author |
| Table name | TblAuthor | TblBooks |
| Text value | Author = Priya Raman | Author = "Priya Raman" |