Answer the question
In order to leave comments, you need to log in
Can IN be replaced by a subquery?
Hotel table:
id | name | cityId
Table of cities:
id | name
Task: to select all hotels located in the city of Moscow, for example.
Solution: SELECT * FROM hotels WHERE cityId = 12
Problem: There may be more than one Moscow (in this example, we do not take into account the country), in addition, it can also be written in Latin.
New solution:
1.
SELECT * FROM cities WHERE name = 'Москва' or name = 'Moscow';
SELECT * FROM hotels WHERE cityId in (12, 19, 23)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question