0
0
MySQLquery~5 mins

First query execution in MySQL

Choose your learning style9 modes available
Introduction
Running your first query helps you see how to get data from a database. It shows you how to ask questions and get answers from stored information.
You want to see all the data in a table for the first time.
You just created a database and want to check if your data is there.
You want to learn how to write simple commands to get information.
You need to confirm the structure and content of a table before working with it.
Syntax
MySQL
SELECT column1, column2 FROM table_name;
Use SELECT to choose which columns you want to see.
FROM tells the database which table to look in.
Examples
This gets all columns and all rows from the employees table.
MySQL
SELECT * FROM employees;
This gets only the name and age columns from the employees table.
MySQL
SELECT name, age FROM employees;
This gets only the id column from the employees table.
MySQL
SELECT id FROM employees;
Sample Program
This query shows all the data stored in the employees table.
MySQL
SELECT * FROM employees;
OutputSuccess
Important Notes
The * symbol means 'all columns'.
Make sure the table name is spelled correctly.
Queries end with a semicolon ; to tell the database you are done.
Summary
Use SELECT to get data from a table.
Use FROM to specify which table to get data from.
The first query helps you understand how to read data from a database.