Skip
Arish's avatar

28. Practice - AND with OR


Exercise: Complex Conditions

Find students in (Python OR Ruby) AND with marks above 75.

Solution

sql
1SELECT * FROM students
2WHERE (course = 'Python' OR course = 'Ruby')
3AND marks > 75;

Another Example

Students aged (12 OR 14) with grade A:

sql
1SELECT * FROM students
2WHERE (age = 12 OR age = 14)
3AND grade = 'A';

Key Point

Always use parentheses to make your logic clear!