Olawale Ahmed Alamu
1 min readNov 10, 2022

--

SQL Daily Practice — Day 10

Hello, Followers, Data Professionals and SQL Enthusiasts.

It’s the 10th day of our SQL daily practice on SQL-PRACTICE-DOT-COM.

Follow Olawale Ahmed Alamu and #sqldailyupdates for #day to #day9 and daily updates. Let’s solve the 10th EASY tag question.

Today, we are looking at SQL IN() function that is used to get values for specific rows on the table.

QUESTION: Show all columns for patients who have one of the following patient_ids: 1, 45, 534, 879, 1000.

PROBLEM ANALYSIS: We are expected to output all columns for patients with patients_ids: 1, 45, 534, 879, 1000.

The patients' table has the following columns:
patient_id(INT),
first_name(TEXT),
last_name(TEXT),
gender(CHAR(1)),
birth_date(DATE),
city (TEXT),
province_id(CHAR(2)),
allergies (TEXT),
height(INT),
weight(INT)

SOLUTION: We write a SELECT * (all columns) statement with a WHERE clause of patient_id IN (1, 45, 534, 879, 1000)

SQL SCRIPT:
-- -- -- -- -- -- —

SELECT *

FROM patients
WHERE patient_id IN (1, 45, 534, 879, 1000);
-- -- -- -- -- -- —

Screenshot of the SQL Script and output attached below:

#sql #health #databases #dataanalytics

--

--

Olawale Ahmed Alamu

CS Grad | Power BI | Microsoft Excel | Learning and Teaching SQL Daily