SQL Syntax
SQL syntax defines the structure and format of commands you write to interact with a database. Think of it as grammar rules for the SQL language — it tells you how to write statements so the database understands what you want.
SQL syntax defines the structure and format of commands you write to interact with a database. Think of it as grammar rules for the SQL language — it tells you how to write statements so the database understands what you want.
For reference, consider the following SQL statements.
SELECT column1, column2
FROM table_name
WHERE condition;
SELECT * FROM students;
SELECT, FROM, WHERE, etc., are not case-sensitive, but writing them in uppercase improves readability.; — this marks the end of a complete command. In the above code, we have two commands.'Delhi'.SELECT*FROM — instead use SELECT * FROM.SELECT and FROM must be separated.SELECT name, age, city
SELECT name, age
FROM students
WHERE age>12;
SELECT name, age FROM students WHERE age>12;
| Symbol | Meaning | Example |
|---|---|---|
* |
Select all columns | SELECT * FROM students; |
, |
Separate columns in a list | SELECT name, age |
' ' |
Wrap string values | WHERE city = 'Delhi' |
= |
Equality condition | WHERE age = 15 |
; |
End of SQL statement | SELECT * FROM students; |
_.SELECT or WHERE as table or column names."student name").; to avoid syntax errors.DELETE FROM students WHERE class = '10A';