Nested Column Queries
This lesson discusses nested queries that return a column of values.
We'll cover the following...
Nested Column Queries
In the previous lesson we examined nested queries that returned a single value. In this lesson we’ll see nested queries that return values belonging to the same column.
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/31lesson.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 1SELECT * FROM ActorsINNER JOIN DigitalAssets ON ActorId=IdWHERE AssetType = ANY (SELECT DISTINCT AssetTypeFROM DigitalAssetsWHERE AssetType != 'Website');-- Query 2SELECT * FROM ActorsINNER JOIN DigitalAssets ON ActorId=IdWHERE AssetType != 'Website';-- Query 3SELECT FirstName, SecondNameFROM ActorsWHERE Id = ANY (SELECT ActorIdFROM DigitalAssetsWHERE AssetType = 'Facebook');-- Query 4SELECT FirstName, SecondNameFROM ActorsWHERE Id IN (SELECT ActorIdFROM DigitalAssetsWHERE AssetType = 'Facebook');-- Query 5SELECT FirstName, SecondNameFROM ActorsWHERE NetworthInMillions > ALL (SELECT NetworthInMillionsFROM ActorsWHERE FirstName LIKE "j%");
-
We’ll use a slightly contrived example this time. Imagine we want to list all the social media accounts for all the actors, except for their personal websites. From our database schema ...
Access this course and 1400+ top-rated courses and projects.