I have a table with the columns word, length, position, count and definition.
I want to make a select of word and definition but just keeping the definition of some words (based on a condition over position, count and length) and the rest of definitions replace them by an empty string.
I’m doing the following query:
SELECT word,definition FROM (SELECT word, definition, position, count FROM words
WHERE position = 5000 AND count < 5 AND length <= 6
AND definition IS NOT NULL
UNION ALL
SELECT word, "" AS definition, position, count FROM words)
ORDER BY position ASC, count DESC
But I end up with duplicated values in the column word.
How can I get this without duplicated values?
Add the inverse WHERE clause to your second set?