samedi 31 octobre 2015

SQLite select query to get one row from multiple rows have same id

I'm trying to get one row from table that have an id column that duplicate in several rows of a SQlite database, but I am getting all rows in table.

This is my table creation and selection query.

CREATE TABLE IMAGES ( MID INTEGER , IMAGE BLOB, ID INTEGER );


SELECT DISTINCT ID, IMAGE  FROM IMAGES;

This what I get

mid | image | id
 1  |  m1   |  1
 2  |  m2   |  1
 3  |  m3   |  1
 4  |  m4   |  2
 5  |  m5   |  3
 6  |  m6   |  3

And this what i want

mid | image | id
 1  |  m1   |  1
 4  |  m4   |  2
 5  |  m5   |  3

Aucun commentaire:

Enregistrer un commentaire