Introduction

The core command that you will use in any SQL infrastructure is SELECT statement. The select statement selects data from your database. This tutorial will introduce you to the syntax of the SELECT statement.

SELECT

One of the most basic queries in SQL is:

In this query, database_table is the name of the database table we are querying. The * specifies all the rows and columns of the specified table. And of course, last but not least, the SELECT statement gives the command to grab and display the data.

So for instance, if you wanted to select a specific row from a table you could use something like this:

Where the_row is a row in the database table.

Let’s step it up a bit. Say you needed to find out what the username of a user in your database, and all you have is their user ID. You could do something like this:

This query is a little more complex and uses the keyword WHERE to specify a parameter that is being passed into the query.

Well that’s the basic syntax for the SELECT statement. Paired with other statements it is very powerful and the core tool used to query a database in SQL.