Note that there are some explanatory texts on larger screens.

plurals
  1. POGet table on the fly with sqlite
    text
    copied!<p>I've a code that display a list of items based on a custom adapter. To display a content of a table no problem but when I need to add a reference to many table it's another thing. Two solution are possible in my point of view:</p> <p>1) Querying the database inside setViewValue (didn't investigate too much this possibility) or 2) Find a way to associate dynamically a column to my other tables</p> <p>(solution for both are welcome) </p> <p>I have a main table where a column called slug is a reference to other tables. These other tables contain some data which I would like to count.</p> <p>Once I have my query I use a SimpleCursorAdapter to display a nice list in android (eg 1024 (2 ref), 2048 (3 ref)...).</p> <p>I think a little schema is probably better than my explanation.</p> <pre><code>Table: A ----------------------- _id | slug | value | ----------------------- 1 | a_a | 1024 | 2 | g_z | 2048 | ----------------------- Table: mytable_a_a ---------------- _id | value | ---------------- 1 | xxx | 2 | yyy | ---------------- Table: mytable_g_z ---------------- _id | value | ---------------- 1 | xxx | 2 | yyy | 3 | zzz | ---------------- The goal is to produce something like ------------------------------- _id | slug | value | count ------------------------------- 1 | a_a | 1024 | 2 2 | g_z | 2048 | 3 ... </code></pre> <p>I've tried something like:</p> <p>SELECT * FROM A UNION SELECT COUNT(*) FROM A.slug;</p> <p>but I'm missing the point and if a solution exists it would be a bit more complicated.</p> <p><em>possible workaround: include a counter in the table a</em></p> <p>Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload