SQL Tutorial – SELECT statement in SQL

Spread the love

You have a table and you want to select some data from it.

Solution –

To select data from a database we use the SELECT statement.

Simple SELECT syntax –

SELECT * FROM city;

This above query will select every rows and columns from the city table. The * asterisks in the SELECT statement is a wildcard for selecting every columns in the city table. And we use the FROM Clause to tell SQL, from which table to select the data.

SELECT only a Subset of column –

Using the wildcard is good if you want to see the structure of the table but might not be always useful. To SELECT only few columns from a table you list the name of the columns separated by comma after the SELECT statement.

Let’s say I want to only select the Name and CountryCode column. Then I will use –

SELECT NAME, CountryCode
FROM city;

This query will only return the columns that we specified in the SELECT statement.

For more SQL Tutorial subscribe to our blog below.

Rating: 1 out of 5.

Leave a Reply