Query tweater (3)
Suppose that you have a people
table, with a bunch of information. This time, you want to find out the age
and country
of married males. Provided that there is a married
column that's 1 when the person in question is married, the following query would work.
SELECT age, country
FROM people
WHERE gender = "male" AND married = 1
Can you use a similar approach for a more specialized query on the tweater
database?
This exercise is part of the course
Intermediate Importing Data in R
Exercise instructions
- Create an R data frame,
specific
, that selects themessage
column from thecomments
table where thetweat_id
is 77 and theuser_id
is greater than 4. - Print
specific
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Connect to the database
library(DBI)
con <- dbConnect(RMySQL::MySQL(),
dbname = "tweater",
host = "courses.csrrinzqubik.us-east-1.rds.amazonaws.com",
port = 3306,
user = "student",
password = "datacamp")
# Create data frame specific
# Print specific