jeudi 26 février 2015

Make one result table from two tables in SQLite

I tag images (table Image) in a data base using a table (ImageAttribute) which has basically two rows - one for attribute type and the other for the value.


The database is:



Image.id
Image.URI
ImageAttribute.imageId
ImageAttribute.attributeType
ImageAttribute.attributeValue


ImageAttribute.imageId refers to Image.id


One image may have many attributes. e.g:



imageId | attributeType | attributeValue
--------+---------------+---------------
1 |COLOR | blue
1 |QUALITY | good
1 |MEMO | some notes for image 1
2 |COLOR | red
2 |QUALITY | good
2 |OBJECTS | cars, trees


From image to image the attributes set may differ.


Is it possible to select all images having attribute COLOR with any value and having QUALITY='good' and display this information in one row e.g.:



id | COLOR | QUALITY
--------+---------------+---------------
1 |blue | good
2 |red | good

Aucun commentaire:

Enregistrer un commentaire