Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make this simple MySQL join select?
    text
    copied!<p>I have the 1st table <strong>registered</strong> and this table contains:</p> <pre><code>uid (int) email (varchar) telephone (varchar) </code></pre> <p>It look like this</p> <pre><code>++++++++++++++++++++++++++++++++++++++++++++++++ + uid + email + telephone + ++++++++++++++++++++++++++++++++++++++++++++++++ + 1 + david@gmail.com + 333-111-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 + erick@gmail.com + 333-222-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 3 + james@gmail.com + 333-333-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 4 + svene@gmail.com + 333-444-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 5 + simon@gmail.com + 333-555-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 6 + peter@gmail.com + 333-666-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 7 + mikka@gmail.com + 333-777-5555 + ++++++++++++++++++++++++++++++++++++++++++++++++ </code></pre> <p>I have the 2nd table <strong>referrers</strong> and this table contains this columns:</p> <pre><code>id (int) uid0 (int) uid1 (int) </code></pre> <p>This second table holds the id which is autoincrement, then uid0 which is the parent user id and uid1 is the user id of the referer</p> <p>It can have these values for example</p> <pre><code>+++++++++++++++++++++++ + id + uid0 + uid1 + +++++++++++++++++++++++ + 1 + 2 + 3 + +++++++++++++++++++++++ + 2 + 2 + 5 + +++++++++++++++++++++++ </code></pre> <p>I know how to echo all registered emails and telephones from <strong>registered</strong> table in the foreach loop.</p> <p>However, I need to join and echo also all referrers (uid1) emails thatbelong to certain user (uid0).</p> <pre><code>+++++++++++++++++++++++ + id + uid0 + uid1 + +++++++++++++++++++++++ + 1 + 2 + 3 + +++++++++++++++++++++++ + 2 + 2 + 5 + +++++++++++++++++++++++ + 3 + 4 + 1 + +++++++++++++++++++++++ + 4 + 4 + 6 + +++++++++++++++++++++++ + 5 + 4 + 7 + +++++++++++++++++++++++ </code></pre> <p>So, the final echo result will look like this:</p> <pre><code>email telephone referers erick@gmail.com 333-222-5555 james@gmail.com, simon@gmail.com svene@gmail.com 333-444-5555 david@gmail.com, peter@gmail.com, mikka@gmail.com </code></pre> <p>How can I do this "threaded" foreach loop?</p> <p>Thanks in advance.</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