Skip to content
Advertisement

Refactoring MySQL query

We came up with this query:

But it must be possible to not have to repeat the subquery twice, as that query is exactly the same.

Is there a way to refactor this query?

Advertisement

Answer

You can replace the or with UNION and replace the subqueries with JOINs:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement