Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>use:</p> <pre><code>SELECT DISTINCT </code></pre> <p>instead of:</p> <pre><code>SELECT </code></pre> <p>or GROUP BY statement.</p> <p>-- EDIT --</p> <p>Example echo:</p> <pre><code>$result = $db-&gt;query("SELECT client.*, GROUP_CONCAT(sys_notes.note SEPARATOR "|") as note, sys_notes.* FROM client LEFT JOIN sys_notes ON sys_notes.client_id = client.id GROUP BY sys_notes.client_id ORDER BY create_date DESC"); ob_start(); ?&gt; &lt;div class="content"&gt; &lt;?php foreach($result as $row) { sprintf("&lt;p&gt;%s %s&lt;br /&gt;%s&lt;br /&gt;%s&lt;/p&gt; %s &lt;ul&gt;", $row['firstname'], $row['lastname'], $row['role'], $row['desc'](example)); foreach(explode("|", $row['note']) as $note) { sprintf("&lt;li&gt;%s&lt;/li&gt;", $note); } sprintf("&lt;/ul&gt;"); } ?&gt; &lt;/div&gt; &lt;? $result = ob_end_clean(); echo $result; </code></pre> <p>-- FINAL UPDATE --</p> <pre><code>&lt;?php try { $db = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e-&gt;getMessage(); } $result = $db-&gt;query('SELECT client . * , GROUP_CONCAT( sys_notes.note SEPARATOR "|" ) AS n, sys_notes.* FROM client LEFT JOIN sys_notes ON sys_notes.client_id = client.id GROUP BY sys_notes.client_id ORDER BY create_date DESC'); ob_start(); ?&gt; &lt;div class="content"&gt; &lt;?php foreach($result as $row) { printf("&lt;p&gt;%s %s&lt;br /&gt;%s&lt;/p&gt; %s &lt;ul&gt;", $row['first_name'], $row['last_name'], $row['issue'], $row['other']); foreach(explode("|", $row['n']) as $note) { printf("&lt;li&gt;%s&lt;/li&gt;", $note); } printf("&lt;/ul&gt;"); } ?&gt; &lt;/div&gt; &lt;?php ob_end_flush(); </code></pre>
    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.
 

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