during my sqlite database, a table named image consists of three fields label, url and index. I authored the next bit of code for fetching data from database: "Choose DISTINCT(label), index from image". During my table there's a label 'Cat' 3 occasions. Based on this code the code must show just one 'Cat' from the database. However it will not working. It brings the 3 'Cat' label. Why it takes place? help me to locate a possible solution. index area differs for those three 'Cat' labels.

Do this:

select label, index from image
where label in (select distinct label from image)

The DISTINCT keyword isn't a function, it identifies that duplicate rows ought to be taken off the outcomes:

When the simple Choose is really a Choose DISTINCT, then duplicate rows are taken off the group of result rows prior to it being came back

What you're attempting to accomplish most likely requires you to definitely group by label:

SELECT label, index FROM image GROUP BY label