Skip
Arish's avatar

7. Practice - Filter by Course


Exercise: Find JavaScript Students

Write a query to find all students enrolled in the JavaScript course.

Task

Select all students where the course is 'JavaScript'.

Solution

sql
1SELECT * FROM students
2WHERE course = 'JavaScript';

Expected Output

idnameagecoursemarksgrade
2Bob12JavaScript78B
7Grace11JavaScript82B

Understanding the Query

  1. SELECT * - Get all columns
  2. FROM students - From the students table
  3. WHERE course = 'JavaScript' - Only JavaScript students

Try These Variations

sql
1-- Find Ruby students
2SELECT * FROM students WHERE course = 'Ruby';
3
4-- Find Python students
5SELECT * FROM students WHERE course = 'Python';
6
7-- Find HTML students
8SELECT * FROM students WHERE course = 'HTML';

Common Errors

sql
1-- Missing quotes around string
2SELECT * FROM students WHERE course = JavaScript;  -- Error!
3
4-- Wrong operator
5SELECT * FROM students WHERE course == 'JavaScript';  -- Error in SQL!

Remember: SQL uses single = for comparison, not ==.