SELECTION & PROJECTION

A select statement is used to select data from a database, choosing which rows are returned. Projection is used for selecting which columns of the table to return.

For example, a selection that selects all columns from all rows in the users table:

SELECT * FROM users;

To select a row for a specific user, we do this:

SELECT * FROM users WHERE username = //username//;

And to select columns from a specific table, we do the following (this is the command for the demo example below):

SELECT (column1, column2, ... column-n) FROM users;

Try our demo below to see selection & projection in action:

SELECT



FROM USER;


Other places we used selection and projection

  • We implemented a selection and projection to display the lists of all users, tags, posts, and locations. We have also used a projection in a 'WHERE username = username' statement to display individual posts and users.