Note that there are some explanatory texts on larger screens.

plurals
  1. PObasic many-to-many sql select query
    primarykey
    data
    text
    <p>I think this should be easy, but it's evading me. I've got a many-to-many relationship between Accounts and Account Groups. An Account can be in zero or more Groups, so I'm using the standard join table.</p> <pre><code>Accounts -------- ID BankName AcctNumber Balance AccountGroups ------------- ID GroupName JoinAccountsGroups ------------------ AID GID </code></pre> <p>I'm using MS Access, FWIW. Also, this is for a low-bandwidth situation, so code optimization isn't as important as simplicity/readability.</p> <p>I'm using php as a presentation layer, so a bare-bones result from Access is fine.</p> <p>As for what to do with the multi-result situation, I actually have two things I'm trying to build. The first lists all the groups in one column thus:</p> <pre><code>Bank AcctNum Balance Groups --------|--------------|----------|---------------- Citi 930938 400 Payroll HSBC 8372933 100 Monthly, Payroll Wells 09837 800 - Chase 8730923 250 Monthly </code></pre> <p>The second is a master-detail list:</p> <pre><code>Name AcctNum Balance ------------|----------|---------- Payroll (2) 500 Citi 930938 400 HSBC 8372933 100 .................................. Monthly (2) 350 HSBC 8372933 100 Chase 8730923 250 .................................. Wells 09837 800 </code></pre> <p>For the master-detail, my plan was just to get a big result set from the db, and munge it in php as needed. Since there's going to be some significant post-processing in php anyway, maybe I should just do three separate queries and do the joining there. (Since I'm more comfortable with that language.)</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.
 

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