Querying Data

This lesson teaches how to query for data in MySQL.

We'll cover the following...

Querying Data

In this lesson we’ll learn how to query the data we have stored in a table. The SELECT statement allows us to retrieve data from tables.

Example Syntax

SELECT col1, col2, … coln

FROM table

WHERE <condition>

Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/8lesson.sh and wait for the MySQL prompt to start-up.

Press + to interact
-- The lesson queries are reproduced below for convenient copy/paste into the terminal.
-- Query 1
SELECT * from Actors;
-- Query 2
SELECT <columns> FROM <TableName>
-- Query 3
SELECT FirstName, SecondName from Actors;
-- Query 4
SELECT FirstName, SecondName from Actors WHERE FirstName="Travolta";
-- Query 5
SELECT FirstName, SecondName from Actors WHERE FirstName="Brad";
-- Query 6
SELECT FirstName, SecondName from Actors WHERE NetWorthInMillions > 500;
-- Query 7
SELECT FirstName, SecondName from Actors WHERE NetWorthInMillions > 0;
Terminal 1
Terminal
Loading...
  1. Execute the following SELECT statement to retrieve all the rows in the table with all the columns.

    SELECT * from Actors;
    

The command reads all the data in the table. The syntax for a simple SELECT command is as ...