Structured Query Language (SQL) is the standard language for interacting with relational databases. In this lesson you will practice reading data with SELECT.
SELECT — chooses the columns to return.FROM — names the table to read from.WHERE — filters rows with a condition.ORDER BY — sorts the result set.LIMIT — restricts how many rows are returned.SELECT name, age FROM users WHERE age > 21 ORDER BY age DESC LIMIT 2;This sandbox contains three tables:
users(id, name, email, age)posts(id, user_id, title, body)comments(id, post_id, user_id, body)Write a query that returns the name and email of all users older than 30, ordered by name ascending.
Structured Query Language (SQL) is the standard language for interacting with relational databases. In this lesson you will practice reading data with SELECT.
SELECT — chooses the columns to return.FROM — names the table to read from.WHERE — filters rows with a condition.ORDER BY — sorts the result set.LIMIT — restricts how many rows are returned.SELECT name, age FROM users WHERE age > 21 ORDER BY age DESC LIMIT 2;This sandbox contains three tables:
users(id, name, email, age)posts(id, user_id, title, body)comments(id, post_id, user_id, body)Write a query that returns the name and email of all users older than 30, ordered by name ascending.