T
T
topuserman2020-12-27 23:59:25
SQL
topuserman, 2020-12-27 23:59:25

What other options are there to write such SQL?

There is a problem , I solved it like this:

select name from Company
left JOIN Trip on Trip.company = Company.id
where Trip.plane = 'Boeing'
GROUP BY name


I am confused by the fact that when joining the flights table to the companies table, it turns out that all records from the flights table for this company are pulled up to one company record (because of this, as a result, I group these records).
Although the first found flight for each company is sufficient to solve the problem, it is not necessary to search for all records in the flights.

Perhaps it can be solved somehow easier?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman, 2020-12-28
SQL

EXISTS

D
Dimonchik, 2020-12-28
@dimonchik2013

why are you grouping instead of limit 1 ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question