SQL Knowledge Center · About ·
Easy Interactive Online SQL Training for Beginners

SQL Joins with WHERE Tutorial - Filter Database Records

Lesson 23 of 31

Joins with WHERE

Interactive SQL Tutorial

You can also use joins with the WHERE clause.

To get a list of characters and TV shows that are not in “Buffy the Vampire Slayer” and are not Barney Stinson, you would run:
SELECT character.name, tv_show.name
FROM character
INNER JOIN character_tv_show
ON character.id = character_tv_show.character_id
INNER JOIN tv_show
ON character_tv_show.tv_show_id = tv_show.id WHERE character.name != 'Barney Stinson' AND tv_show.name != 'Buffy the Vampire Slayer';


Can you return a list of characters and TV shows that are not named “Willow Rosenberg” and in the show “How I Met Your Mother”?

SQL:

Query Result:

Available Tables: