Skip to content
Advertisement

Two conditions based on subquery. How to shorten it?

I have working query basing on 2 subqueries.

I would like to know what to do to do not have to paste 2 times my big sql query and just use this two conditions in one line? Is this possible?

Advertisement

Answer

I am guessing that you really want:

Unlike your query, this guarantees that the two columns are on the same row in your query. That is not what your query does, but I’m guessing it is your intention.

If you really want to check if either occurs anywhere, then you can use a CTE:

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