Databases SQL Reporting by Example Day 1: Joining Tables 7th Grade Science

György Varga
György Varga
19,198 Points

Case sensitivity

Hi!

Here is my solution where you don't need to check the subjects table if that the name of the subjects start with uppercase or lowercase letter.

SELECT DISTINCT teachers.id, teachers.first_name, teachers.last_name FROM teachers
INNER JOIN classes ON teachers.id = classes.teacher_id
INNER JOIN subjects ON classes.subject_id = subjects.id
WHERE subjects.grade = 7 AND UPPER(subjects.name) = UPPER("sCieNce");

2 Answers

Steven Parker
Steven Parker
201,997 Points

You've definitely discovered the way to eliminate case sensitivity. :+1:

And LOWER would also do the same job. But you don't need to use the function twice when comparing literals, just be sure your literal matches the case you're converting to:

WHERE subjects.grade = 7 AND UPPER(subjects.name) = "SCIENCE";