T
T
tigra2016-05-18 11:45:39
MySQL
tigra, 2016-05-18 11:45:39

What is the correct way to write a query with DISTINCT or GROUP BY?

there is a request

(SELECT * FROM notification_role WHERE notification_role.role="curator") UNION (SELECT * FROM notification_user WHERE notification_user.user_id=15)

badcce3c4824425798830ac6141f37d6.png
Question: how to combine 2 queries on the trigger field so that there are only unique values

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Tsvetkov, 2016-05-18
@tigroid3

SELECT DISTINCT [trigger] FROM notification_role WHERE notification_role.role="curator"
UNION 
SELECT DISTINCT [trigger] FROM notification_user WHERE notification_user.user_id=15

UNION already collects only unique attributes.
UNION ALL - everything.

D
Dima Pautov, 2015-07-24
@bootd

What if there are a lot of sizes? What, dozens of different files to keep? Proceed from the situation, if there are a lot of styles and few sizes, then your option is suitable, and when there are few styles, but there are a lot of sizes, it’s easier to keep everything in 1 file!

A
Alexander Petrov, 2015-07-24
@dzhiriki

And what prevents you from opening devtools and checking?
The browser loads all styles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question