Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML listing of recordset, resulting from a join on two tables that relate one-many
    primarykey
    data
    text
    <p>I have two tables, that relate via a one-to-many relationship i.e </p> <pre><code>tableOne (1)----------(*) tableTwo </code></pre> <p>Given the basic schema below</p> <pre><code>tableOne { groupID int PK, groupTitle varchar } </code></pre> <p>and</p> <pre><code>tableTwo { bidID int PK, groupID int FK } </code></pre> <p>Consider the two tables yield the following record-set based on joining the tables on the <code>tableOne.groupID = tableTwo.groupID,</code></p> <pre><code>tableOne.groupID | tableOne.groupTitle | tableTwo.bidID | tableTwo.groupID ________________________________________________________________________________ 1 | Physics Group | 1 | 1 2 | Chemistry Group | 2 | 2 2 | Chemistry Group | 3 | 2 1 | Physics Group | 4 | 1 </code></pre> <p>I would like to list such a record-set in an HTML table as follows: </p> <pre><code>tableOne.groupID | tableOne.groupTitle | tableTwo.bidID | tableTwo.groupID ________________________________________________________________________________ 1 | Physics Group | 1 | 1 | Physics Group | 4 | 1 2 | Chemistry Group | 2 | 2 | Chemistry Group | 3 | 2 </code></pre> <p>I'm interested in finding out if this can be done in SQL, or alternatively finding out ways of listing such a record-set in HTML using good standards.</p> <p>The solution that comes to mind is simply iterating through the record-set and leveraging a sentinel to list all records with the same <code>tableOne.groupID</code> grouped in a single row <code>&lt;tr&gt;</code> - and also listing <code>tableOne.groupID</code>s once as a unique identifier of that record-group. However I don't want to go down that path as I would like to avoid mixing code with HTML if possible.</p>
    singulars
    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.
    1. This table or related slice is empty.
    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