Filtering rows using AND operator in SQL, Python and R

Given a table or dataframe named students as shown below, get all the records from the table or dataframe where the student hails from India and specifically, comes from Mumbai.

| ---------- | ------------ | ------------ | --------------- |
| student_id | student_name | student_city | student_country |
| ---------- | ------------ | ------------ | --------------- |
| 1          | John         | Atlanta      | USA             |
| ---------- | ------------ | ------------ | --------------- |
| 2          | Hari         | Mumbai       | India           |
| ---------- | ------------ | ------------ | --------------- |
| 3          | Ali          | Dubai        | UAE             |
| ---------- | ------------ | ------------ | --------------- |
| 4          | Jenny        | Berlin       | Germany         |
| ---------- | ------------ | ------------ | --------------- |
| 5          | Lisa         | Berlin       | Germany         |
| ---------- | ------------ | ------------ | --------------- |
| 6          | Priya        | Delhi        | India           |
| ---------- | ------------ | ------------ | --------------- |
| 7          | Wong         | Beijing      | China           |
| ---------- | ------------ | ------------ | --------------- |
| 8          | Julius       | Rome         | Italy           |
| ---------- | ------------ | ------------ | --------------- |
| 9          | Alonso       | Atlanta      | USA             |
| ---------- | ------------ | ------------ | --------------- |
| 10         | Noor         | London       | UK              |
| ---------- | ------------ | ------------ | --------------- |

Filtering rows using AND operator in SQL:

SELECT * 
FROM students
WHERE student_country = 'India'
AND student_city = 'Mumbai'

Filtering rows using AND operator in Python:

You must have the pandas library installed to run this snippet of code.

import pandas as pd

# Method 1
students[(students.student_country == 'India') & (students.student_city == 'Mumbai')]

# Method 2
students.loc[(students.student_country == 'India') & (students.student_city == 'Mumbai')]

# Method 3
students.query('student_country == "India" and student_city == "Mumbai"')

Filtering rows using AND operator in R:

You must have the dplyr library installed to run method 4.

# Method 1
students[students$student_country == "India" & students$student_city == "Mumbai",]

# Method 2
students[which(students$student_country == "India" & students$student_city == "Mumbai"),]

# Method 3
subset(students, student_country == "India" & student_city == "Mumbai")

# Method 4
library('dplyr')

filter(students, student_country == "India" & student_city == "Mumbai")

Result:

student_id student_name student_city student_country
         2         Hari       Mumbai           India