Select Data
To retrieve data from a data base, we use the SELECT statement.
Specify Columns
By specifying the column names, we can choose which columns to select:
SELECT brand, year FROM cars;
Return ALL Columns
Specify a * instead of the column names to select all columns:
SELECT * FROM cars;
Display Table
To check the result we can display the table with this SQL statement:
SELECT * FROM cars;
PostgreSQL Operators
Greater Than
The > operator is used when you want to return all records where a columns is greater than a specified value.
Return all records where the year is greater than 1975:
SELECT * FROM cars
WHERE year > 1975;
Less Than or Equal To
The <= operator is used when you want to return all records where a column is less than, or equal to, a specified value.
Return all records where the year is less than or equal to 1975:
SELECT * FROM cars
WHERE year <= 1975;
Reference
https://www.w3schools.com/postgresql/postgresql_operators.php
Top comments (0)