E
E
eldar_web2018-07-04 12:04:13
MySQL
eldar_web, 2018-07-04 12:04:13

How to write a SQL query correctly with a certain condition?

I can't think of a request.
There are two tables prices and price_items (belongs to prices - references price_id).
For these two tables there is one table of ratings - ratings with fields:
type_id : here can be id prices or price_items type_name
: ' price' or 'price_items'
ball : respectively rating if it does not have an entry, then we take ball from the parent price ? It doesn't seem to work like this:

SELECT price_ratings.ball FROM price_ratings, price_items
WHERE price_ratings.type_id IN (CASE
WHEN price_ratings.type_id != price_items.id THEN price_items.price_id
END)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2018-07-04
@idShura

You've already been answered here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question