2
I have the following select:
SELECT linha._id,
linha.numero_onibus,
linha.nome,
percurso.nome
FROM linha
INNER JOIN percurso ON linha._id = percurso.id_linha
AND (linha.numero_onibus LIKE ? OR linha.nome LIKE ?) COLLATE NOCASE
When the condition linha.numero_onibus LIKE ?
is false, the query does not return results. What and have to do to that, even if the condition linha.numero_onibus LIKE ?
is false, he proceed with the consultation and return me the results of linha.nome LIKE ?
?
Your query looks OK, except for the second part of the ON, which should be on WHERE. But this makes no difference in the result in some Sgbds (not sure how it is in sqlite, so it is worth testing.
– bfavaretto
I believe the problem occurred by query logic. The condition
linha.numero_onibus LIKE ? OR linha.nome LIKE ?
will always bring results oflinha.numero_onibus LIKE ?
because this condition will always be true. As I was also having performance problems, I ended up creating a table FTS3 to solve the query problem.– Marco Aurélio