I'm creating Android countries quiz based on built-in SQLite. One of the task is to choose correct continent (from 4 options) for given country. I use the following DB structure:
continents: ID | name
countries: ID | continent (foreign key) | name | capital
App choose 4 random rows and return Cursor this way:
return db.rawQuery("SELECT country.name, continent.name FROM "+COUNTRIES_TABLE_NAME+" country LEFT JOIN "+CONTINENTS_TABLE_NAME+" continent ON country.continent = continent.id ORDER BY RANDOM() LIMIT 4", null);
What is the problem: SQLite can random countries that are from the same continent, then I have two or more equal answers. I wanted to avoid this problem adding DISTINCT:
SELECT country.name, DISTINCT continent.name...
Then I got an error (because of syntax, probably). What do I have to do then?