You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My problem is the following, I want to make a query where I bring all (*) of a table (ELEMENT) and another table (IMAGE) may have 3 different images, but I only want to bring the first element, unfortunately with my query brings me 3 times the same ELEMENT but with different IMAGE since I have 3.
I want to bring 1 image from table A, B and C, but in the table B or C i could have 4 or 5 images extra.
I tried with DISTINCT but it doesn't work.
I also don't understand why SQFLite doesn't support subqueries, if I want to do another SELECT, why doesn't it allow me to do it?
finalList<Map<String, Object?>> res =await database.rawQuery(
''' SELECT DISTINCT e.*, a.id AS aId, a.name AS aName, [...] b.id AS bId, b.name AS bName, [...] c.id AS cId, c.name AS cName, [...] FROM element_table e LEFT JOIN image_table a ON e.imageId = a.id LEFT JOIN element_picture_table ep ON ep.elementId = e.id /// nested table with ids between PICTURE TABLE and ELEMENT TABLE LEFT JOIN picture_table p ON ep.pictureId = p.id LEFT JOIN image_table b ON b.id= p.imageOne /// Here in the IMAGE TABLE B, i could have 2 or 5 images... LEFT JOIN image_table c ON c.id= p.imageTwo WHERE [...] ORDER BY [...] ''',
[
...
],
);
I try to do this because i don't want to use dart logic, this to avoid a lot of process extra, imagine that I have 2000 rows in the database? if I do some kind of map or for, my process takes time.
My problem is the following, I want to make a query where I bring all (*) of a table (ELEMENT) and another table (IMAGE) may have 3 different images, but I only want to bring the first element, unfortunately with my query brings me 3 times the same ELEMENT but with different IMAGE since I have 3.
I want to bring 1 image from table A, B and C, but in the table B or C i could have 4 or 5 images extra.
I tried with DISTINCT but it doesn't work.
I also don't understand why SQFLite doesn't support subqueries, if I want to do another SELECT, why doesn't it allow me to do it?
I try to do this because i don't want to use dart logic, this to avoid a lot of process extra, imagine that I have 2000 rows in the database? if I do some kind of map or for, my process takes time.
This can be mi Object :
The text was updated successfully, but these errors were encountered: