Select By ID

Query all columns for a city in the CITY table with the ID 1661.

The CITY table is described below.

FieldType
IDNUMBER
NAMEVARCHAR(20)
COUNTRYCODEVARCHAR(20)
DISTRICTVARCHAR(20)
POPULATIONNUMBER
SELECT
    Id,
    [Name],
    CountryCode,
    District,
    Population
FROM City
WHERE Id = 1661;

As per the logical query processing phase, our query will start from the FROM clause. The query will take the CITY table as the input table and filter the row for which the ID column’s value is 1661. Hence we used the predicate Id = 1661.

In the last step, we selected the required attributes ( in this case all attributes). Note that here we can use wildcard character * as well to get all attributes but it’s a bad practice to use it. Always explicitly specify the columns that we required.