I have following query, which works, but I guess it can it be improved to something more efficient, how to do it?
- all the values are from 1 table
- 1st part of the result are always 2 rows having some a relation forming 1 row with all the fields set
- 2nd part of the result are rows with some condition not participating in the first part which already have the right fields
SELECT
row1.field1 AS field1,
row1.field2 AS field2,
row2.field3 AS field3,
FROM
table1 row1
JOIN
table1 row2
ON
row1.field = row2.field_reference
UNION ALL
SELECT
field1,
field2,
field3,
FROM
table1
WHERE
condition = 'I_am_sure_those_rows_are_not_returned_in_the_SELECT_above'