...

/

Combining Conditions

Combining Conditions

This lesson discusses how to combine multiple conditions in a MySQL query.

We'll cover the following...

Combining Conditions

In this lesson we’ll learn how to combine multiple conditions in the WHERE clause.

Example Syntax

SELECT col1, col2, … coln

FROM table

WHERE col3 LIKE "%some-string%"

AND

col4 = 55;

Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/10lesson.sh and wait for the MySQL prompt to start-up.

Press + to interact
-- The lesson queries are reproduced below for convenient copy/paste into the terminal.
-- Query 1
SELECT * FROM Actors WHERE FirstName > "B" AND NetWorthInMillions > 200;
-- Query 2
SELECT * FROM Actors WHERE FirstName > "B" OR NetWorthInMillions > 200;
-- Query 3
SELECT * FROM Actors WHERE (FirstName > 'B' AND FirstName < 'J') OR (SecondName >'I' AND SecondName < 'K');
-- Query 4
SELECT * FROM Actors WHERE NOT(FirstName > "B" OR NetWorthInMillions > 200);
-- Query 5
SELECT * FROM Actors WHERE NOT NetWorthInMillions = 200;
-- Query 6
SELECT * FROM Actors WHERE (NOT NetWorthInMillions) = 200;
-- Query 7
SELECT * FROM Actors WHERE FirstName > "B" XOR NetWorthInMillions > 200;
Terminal 1
Terminal
Loading...
  1. We can use the AND operator to query for actors whose first name starts with the letter ‘B’ or any character thereafter and whose net worth is greater than 200 ...

Access this course and 1400+ top-rated courses and projects.