Estimated reading time: 2 minutes
You have now started to understand your database structure and want to extract data from it.
Data analytics projects can have lots of data, you need a way to get to what you need quickly and easily.
The question now becomes how would you achieve this?
The easiest way is to add a where clause into your select statement.
On the below SQLite database, we are going to retrieve certain records from the name column, using our sql query.
The objective is that when we run the SQL code, it only returns the records we asked it to show us.
Writing the SQL code to return all rows where name = Ireland
Using the below code to extract our data:
select * from error_dbase.country where name = "Ireland"
it returns the following from the database
But what if we want to return more than one value?
Then you would just use an “in” statement, and the SQL code would be changed as follows:
select * from error_dbase.country where name in ("Ireland","Italy")
yielding a result as follows:
and this would also work if we had more than one of the same values as follows:
So to recap, we can choose one value on its own, using the “where” clause
we can use the “in” clause to ask the code to return records of multiple selections.
To see a video tutorial explaining the concepts above, see below: