Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SQLite query order issue
    primarykey
    data
    text
    <p>How can I query a database to display a table with data by two different IDs, yet alternate each ID per row and yet still order by time. For example. Database has 10 Elements of ID1 and 10 Elements of ID2.</p> <p>I need it to be:</p> <pre><code>ID1 #data #2minutes ago ID2 #data #15minutes ago ID1 #data #4minutes ago ID2 #data #50minutes ago </code></pre> <p>Any Ideas?</p> <p>UPDATE: The number of ID's must be able to differ from one to n and also I am currently trying to do this via the SQLite.query() method.</p> <p>UPDATE 2: The #data represent columns of data within that row, not just one, so there could be 5 columns for example. Also, The data has to be returned via a cursor.</p> <p>UPDATE 3: Further elaboration, below is a table and expected result I am trying to achieve.</p> <p>The input table (Ordered by Time)..</p> <pre><code>id | name | number | time 01 Tim 561481 2 minutes ago 02 Jon 951484 5 minutes ago 02 Jon 978284 7 minutes ago 04 Zen 171484 15 minutes ago 04 Zen 171484 17 minutes ago 03 Ken 468488 20 minutes ago 02 Jon 978284 32 minutes ago </code></pre> <p>And the output: note, I need to alternate the Id's within the data base where possible and yet still order the whole thing by time, for example:</p> <pre><code>id | name | number | time 01 Tim 561481 2 minutes ago 02 Jon 951484 5 minutes ago 04 Zen 171484 15 minutes ago 03 Ken 468488 20 minutes ago 02 Jon 978284 7 minutes ago 04 Zen 171484 17 minutes ago 02 Jon 978284 32 minutes ago </code></pre> <p><strong>UPDATE 4:</strong> Prefer a very simple solution such as a complex yet clean sql query etc. <strong>UPDATE 5:</strong> Despite having to give the bounty away, this question still has not been answered with an simple solution to do what I desire.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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