Back to subject
MySQL/Introduction to MySQL

Run Your First Query

Practical lesson

Let's run the smallest possible MySQL query and read exactly what each part does.

SELECT "Hello, MySQL!" AS greeting; SELECT is the command that asks MySQL to return some value. Here it isn't even reading from a table yet, it's just returning the literal text you gave it.

The AS greeting part renames the returned column. Without it, MySQL would label the column with the raw text itself, which is messy to read. Giving it a clear name is a habit you'll use constantly once you're pulling real columns from real tables.

The semicolon ; at the end tells MySQL "this statement is finished." Every SQL statement in this course ends with one forgetting it is one of the most common beginner mistakes, especially when running multiple statements together.

Notice the result comes back as a small table, even for one fixed value: one column (greeting), one row (Hello, MySQL!). Every single query result in MySQL, no matter how complex, takes this same shape: rows and columns.

Try it yourself
Code

Starter example

Code
SELECT "Hello, MySQL!" AS greeting;
Live preview
+-----------------+
| greeting        |
+-----------------+
| Hello, MySQL!   |
+-----------------+
1 row in set