Session Ready
Exercise

More advanced SQL queries

The SQL query example given in the previous example, was the following:

SELECT age 
  FROM people 
    WHERE gender = "male"

Suppose now that the people table also contains a country and married column you want to import. This time, you want to find out the age and country of married males. The query can be extended as follows, provided that there is a married column that's 1 when the person in question is married:

SELECT age, country 
  FROM people 
    WHERE gender = "male" AND married = 1
Instructions
100 XP
  • Create an R data frame, specific, that selects the message column from the comments table where the tweat_id is 77 and the user_id is greater than 4.
  • Create a data frame, short, that selects the id and name columns from the users table where the number of characters in the name is under 5. Use the SQL function CHAR_LENGTH() inside the WHERE clause of the SQL query.
  • Print specific and short