Skip to main content
Remove tags from title and improve some grammar and formatting
Source Link

Android sqlite: How to select distinct valusevalues from 1one column in table?

iI am developing a restaurant menu app in androidAndroid. My app has 1one database table which hashas the following columns id(primary key) ,category, item name. Category:

  • id (primary key)
  • category
  • item name

The category column shows the category of item such as veg  , non veg, snacks etc. It has duplicate values. i and I want to select only distinct values from this column. iI have tried raw query,the following but it is not working, plz help me. here is my raw query if anyone can provide a solution:

String query = "SELECT DISTINCT category FROM todo"; Cursor cursor = database.rawQuery(query,null); if (cursor != null) { cursor.moveToFirst(); } return cursor; 

Android sqlite: How to select distinct valuse from 1 column in table?

i am developing restaurant menu app in android. My app has 1 database table which has columns id(primary key) ,category, item name. Category column shows the category of item such as veg  , non veg, snacks etc. It has duplicate values. i want to select only distinct values from this column. i have tried raw query, but it is not working, plz help me. here is my raw query

String query = "SELECT DISTINCT category FROM todo"; Cursor cursor = database.rawQuery(query,null); if (cursor != null) { cursor.moveToFirst(); } return cursor; 

How to select distinct values from one column in table?

I am developing a restaurant menu app in Android. My app has one database table which has the following columns:

  • id (primary key)
  • category
  • item name

The category column shows the category of item such as veg, non veg, snacks etc. It has duplicate values and I want to select only distinct values from this column. I have tried the following but it is not working if anyone can provide a solution:

String query = "SELECT DISTINCT category FROM todo"; Cursor cursor = database.rawQuery(query,null); if (cursor != null) { cursor.moveToFirst(); } return cursor; 
added 10 characters in body
Source Link
Mattia Maestrini
  • 33k
  • 15
  • 90
  • 95

i am developing restaurant menu app in android. My app has 1 database table which has columns id(primary key) ,category, item name. Category column shows the category of item such as veg , non veg, snacks etc. It has duplicate values. i want to select only distinct values from this column. i have tried raw query, but it is not working, plz help me. here is my raw query

 String query ="SELECT= "SELECT DISTINCT category FROM todo";  Cursor cursor = database.rawQuery(query,null);  if (cursor != null) {   cursor.moveToFirst();  }    return cursor; 

i am developing restaurant menu app in android. My app has 1 database table which has columns id(primary key) ,category, item name. Category column shows the category of item such as veg , non veg, snacks etc. It has duplicate values. i want to select only distinct values from this column. i have tried raw query, but it is not working, plz help me. here is my raw query

 String query ="SELECT DISTINCT category FROM todo";  Cursor cursor = database.rawQuery(query,null);  if (cursor != null) {   cursor.moveToFirst();  }  return cursor; 

i am developing restaurant menu app in android. My app has 1 database table which has columns id(primary key) ,category, item name. Category column shows the category of item such as veg , non veg, snacks etc. It has duplicate values. i want to select only distinct values from this column. i have tried raw query, but it is not working, plz help me. here is my raw query

String query = "SELECT DISTINCT category FROM todo"; Cursor cursor = database.rawQuery(query,null); if (cursor != null) { cursor.moveToFirst(); }   return cursor; 
Source Link
sagar
  • 1.9k
  • 5
  • 31
  • 47

Android sqlite: How to select distinct valuse from 1 column in table?

i am developing restaurant menu app in android. My app has 1 database table which has columns id(primary key) ,category, item name. Category column shows the category of item such as veg , non veg, snacks etc. It has duplicate values. i want to select only distinct values from this column. i have tried raw query, but it is not working, plz help me. here is my raw query

 String query ="SELECT DISTINCT category FROM todo"; Cursor cursor = database.rawQuery(query,null); if (cursor != null) { cursor.moveToFirst(); } return cursor;