I'm finding it hard to understand the IN query. So, I will try to break down how I am going to understand it in this blog. So we have this preliminary longer code at the start.
SELECT * FROM exercise_logs WHERE type = "biking" OR type = "hiking" OR type = "tree climbing" OR type = "rowing";
The code above could be improved by using the IN operator.
SELECT * FROM exercise_logs WHERE type IN ("biking", "hiking", "tree climbing", "rowing");
According to w3schools, the IN operator allows us to specify multiple values in a WHERE clause. The IN operator is a shorthand for multiple OR conditions.
Basically, the improved code can be read as:
Select all rows from the table exercise_logs where the type is biking or hiking or tree climbing or rowing.
Now, that I understand this operator, I was able to use it in the following challenge.
Comments
Post a Comment