We Learn SQL #10 | Subqueries with the IN operator in SQL
Vložit
- čas přidán 5. 09. 2024
- Learn SQL Subqueries with the IN operator. This is extremely helpful, thanks to which you will write better and clearer SQL queries.
If you want to learn or practice SQL, check out learnsql.com/.
Hello, my name is Adrian. Welcome to another video in the series about SQL basics. We already know simple subqueries that return a single value. We talked about them in the previous video. This time, we’re going to tackle slightly more advanced examples, where a subquery returns more than one value. So, without further ado, let’s get started!
Let’s learn SQL together!
👌 Subscribe to our channel and leave a comment!
👌 Do you want to learn SQL? Go to LearnSQL.com and choose the course or track that is best for you!
👌 Join us on Facebook: / welearnsql .
🔊 Music: www.bensound.com/
How do you not have more views and subscribers? Your explanation on subqueries is by far the best out of the 5 others I've watched.
I think the answer in 4:20 has one error.
In the table *city*, we do not have column named 'city_id'.
The correct one is
SELECT * FROM city
WHERE id IN (SELECT city_id FROM university WHERE rank
Muy buena explicación, solo un error en el código de
"SELECT * FROM city WHERE city_id IN (...) ”
Ya que la tabla city, no tiene la columna city_id, si no que la columna “id”, entonces la query correcta debiese ser:
"SELECT * FROM city WHERE id IN (...);
Propongo usar la convención de nombres para las T-SQL PascalCase.
Muchas gracias por los videos! Son muy buenos. Exito en tu canal.
Very good explanation.
The last example has a small flaw.
▶ "SELECT * FROM city WHERE city_id IN ..." instead of "... WHERE id IN ..."
Yes, this I too noticed and it should be rectified.
But i must say 'explained very well'.
I think there is a mistake in the second query. It should be:
Select *
From city
WHERE id IN
(SELECT city_id FROM university WHERE rank
Last 2 queries can also be done using joins rt?
Low amount of views and such an extraordinary level of explanation, thank you!
Very helpful! Great work. I hope you keep working here and make more videos.
Shouldnt we use WHERE id(insted of city_id)? 4:23
I guess the only challenge in the last query would be if we needed to show the actual rankings column for the output
thanks really much
great explanation! thank you
thanks!
is't better use distinct in subquery?
`SELECT * FROM city WHERE id IN (SELECT DISTINCT city_id FROM university WHERE rank
Is the "IN" operator just a better way of listing multiple results instead of using "OR" repeatedly?
i.e. you could have just used
WHERE
country = "USA" OR "UK"
The result in 2:12 only should have one column "ID". Learn yourself sql before teaching.