Skip to content

MySQL Tutorial SQL Basics

SQL Statements

Lesson 14 of 308 2 min read By Deepak Paswan Updated Oct 5, 2026

An SQL statement is one complete instruction you give to MySQL: “create this table”, “add this row”, “show me these rows”.

query.sql
SQL
SELECT 'one statement' AS example;
Output
OUTPUT
+---------------+
| example       |
+---------------+
| one statement |
+---------------+
1 row in set

The parts of a statement

Most statements follow the same pattern: a command word, then what it applies to, then optional clauses that refine it.

query.sql
SQL
CREATE TABLE tags (id INT PRIMARY KEY, label VARCHAR(30));
INSERT INTO tags (id, label) VALUES (1, 'sql');
SELECT id, label FROM tags WHERE id = 1;
Output
OUTPUT
+----+-------+
| id | label |
+----+-------+
|  1 | sql   |
+----+-------+
1 row in set
PieceExampleJob
Command (verb)SELECTWhat to do
ObjecttagsWhich table (or other object)
ClauseWHERE id = 1A condition, an order, a limit and so on
Terminator;Ends the statement

The semicolon

The semicolon tells the client where one statement ends. It is not part of the statement the server runs. This matters because:

  • You can put several statements on one line or many lines, and the client splits them at each ;.
  • A statement without a semicolon is simply “not finished yet” in the mysql client.
  • Some programming languages send one statement per call and do not want the semicolon at all. Others accept several. Your language’s documentation will say.
query.sql
SQL
SELECT 1 AS a;
SELECT 2 AS b;
Output
OUTPUT
+---+
| a |
+---+
| 1 |
+---+
1 row in set

+---+
| b |
+---+
| 2 |
+---+
1 row in set

Each statement produced its own result.

Statements spread over lines

SQL ignores extra spaces and line breaks. These two statements are identical to MySQL:

query.sql
SQL
SELECT name,price FROM (SELECT 'Pen' AS name, 10 AS price) AS t WHERE price>5;

SELECT name,
       price
FROM   (SELECT 'Pen' AS name, 10 AS price) AS t
WHERE  price > 5;
Output
OUTPUT
+------+-------+
| name | price |
+------+-------+
| Pen  |    10 |
+------+-------+
1 row in set

+------+-------+
| name | price |
+------+-------+
| Pen  |    10 |
+------+-------+
1 row in set

Use the second style. One clause per line makes SQL much easier to read, review and debug.

Statements you will see in this course

KindExamples
Reading dataSELECT
Changing dataINSERT, UPDATE, DELETE, REPLACE
Changing structureCREATE, ALTER, DROP, TRUNCATE, RENAME
Access controlCREATE USER, GRANT, REVOKE
TransactionsSTART TRANSACTION, COMMIT, ROLLBACK
InformationSHOW, DESCRIBE, EXPLAIN
info
MySQL-specific statements
SHOW, DESCRIBE, USE and REPLACE are MySQL statements. They are not part of standard SQL. The standard way to look at structure is the INFORMATION_SCHEMA views, which MySQL also supports.