1
How can I join 2 query results without mixing them?
For example: The first query results in names starting with Victor, the second results in names containing Victor.
Result of first consultation:
Vitor A...
Vitor B...
Vitor C...
Vitor D...
Result of the second consultation:
Antonio Vitor...
João Vitor...
Matheus Costa Vitor
Vitor A...
Vitor B...
Vitor C...
Vitor D...
William Vitor
Uniting them results in:
Antonio Vitor...
João Vitor...
Matheus Costa Vitor
Vitor A...
Vitor B...
Vitor C...
Vitor D...
William Vitor
My goal is to result in:
Vitor A...
Vitor B...
Vitor C...
Vitor D...
Antonio Vitor...
João Vitor...
Matheus Costa Vitor
William Vitor
I am using the following query:
SELECT Nome
FROM Pessoa
WHERE Nome LIKE 'Vitor%'
UNION
SELECT Nome
FROM Pessoa
WHERE Nome LIKE '%Vitor%'
can insert into a temporary/in-memory table to return in the same order they were inserted
– Ricardo Pontual
Yeah, if it doesn’t make it too slow.
– Focos