In the context of this exercise, what are some other useful things that SQL lets us do?
Answer
SQL provides us with a lot of useful functionality for interacting with databases.
When retrieving data from a database, we can use SQL to select specific rows based on some condition. For example, this will retrieve just the rows that satisfy the condition following the WHERE clause, which is when the value under the col column is greater than 50.
SELECT col FROM table
WHERE col > 50;
SQL also lets us aggregate data, which means to summarize observations for groups of data. For example, SQL provides aggregate functions to get the sum or the average of all values of a column, returning a single value, or summary.
In addition, we can even combine multiple tables using the JOIN clause. We can combine tables by essentially stacking all the rows of one table on top of the other, or we can combine them based on some conditions or on matching values of some columns only.
These are only a few of the many useful features that SQL provides. Feel free to check out some SQL documentation or the Codecademy SQL courses for more useful things that SQL lets us do!
This will first return all (*) columns from the ‘users’ table,
then it will only return rows where the gender column has a value of ‘Female’ (make sure to wrap Female in quotes (’’), as Female is of the string data type
Yes, You are right I did a mistake in there, you need to use WHERE only once
To select multiple data to filter means both conditions must satisfy, you can use AND: SELECT * FROM users WHERE membership_id <= ‘2000’ AND gender = ‘Male’;
You can use OR if either of the conditions is true or both are true: SELECT * FROM users WHERE membership_id <= ‘2000’ OR gender = ‘Male’;