With a simple query this is not possible.
You could, however, implement a function or procedure to compare the texts, but do not know and did not find a text difference algorithm implemented for Mysql.
Anyway, doing it on the consult doesn’t pay. It would be better to recover the base texts and make use of some library of your language or tool available on the server to perform the comparison.
If you really need to retrieve this through a query, another strategy would be to reshape the base to store each line of text in another table separately. Then you could easily do a query like this:
SELECT LINHA
FROM TEXTO
WHERE TEXTO.ID = 'id-texto-1'
AND TEXTO.LINHA NOT IN (
SELECT LINHA
FROM TEXTO
WHERE TEXTO.ID = 'id-texto-2'
)
UNION ALL
SELECT LINHA
FROM TEXTO
WHERE TEXTO.ID = 'id-texto-2'
AND TEXTO.LINHA NOT IN (
SELECT LINHA
FROM TEXTO
WHERE TEXTO.ID = 'id-texto-1'
)
The disadvantage of this is that the queries do not consider the order of the lines, but if it is not a problem should work.
It would even give to create a function that converts the text into a temporary table if you do not want to save the lines separately, but this will make the query much slower and is a little complicated to implement.
Can you post your tables as they are? and some data of them as it comes and as I should come?
– Marco Souza