N
N
Nikolay2016-02-26 00:32:58
MySQL
Nikolay, 2016-02-26 00:32:58

How to formulate a MySQL query?

There are 3 tables.
company:

  • company_id - binding column
prices:
  • price_id
  • company_id
  • description_id
  • price - the cost itself
description_service:
  • description_id - binding column
  • service_name

You need to parse companies with a filter by the prices of the services described in the description_service table. Naturally, one company can have many services, and each has its own price. I didn’t find anything similar on the forums and manuals, maybe I just looked inattentively. This is why I had to ask for help. Thanks in advance)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kovalsky, 2016-02-26
@tryvols

They searched badly.

SELECT company_id FROM prices as p
INNER JOIN description_service as ds ON ds.description_id = p.description_id
WHERE some condition

E
Egor, 2016-03-26
@egormmm

SELECT company_id, company_name FROM company с
JOIN prices p USING(company_id)
JOIN description_service ds USING(description_id)
WHERE p.price some_cond AND ds.description_id some_cond

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question