title: SQL query to get state,then city and address and zip
body: <p>I'm trying to get data from database in this format:</p>
  
  <pre><code>    state
      |__city
      |  |__address
      |  |__zip
  </code></pre>
  
  <p>I want all unique states and cities with all addresses and zip codes concatenated.</p>
  
  <p>Here's what I've tried:</p>
  
  <pre><code>SELECT
    state,
    GROUP_CONCAT('(',address,';)') AS address,
    GROUP_CONCAT('(',zip,';)') AS zip
  FROM location
  WHERE   
    sername='ABC@gmail.com'
  GROUP BY state,city
  </code></pre>
  
  <p><strong>UPDATE</strong><br>
  There is problem with concatenation. I want the data in this format: </p>
  
  <pre><code>state        city     address               zip     
  Karnataka   BANGALORE   (sdbsbd);(dsdsds);  NULL
  </code></pre>
  
  <p>and I'm getting data as</p>
  
  <pre><code>state        city     address               zip     
  Karnataka   BANGALORE   (sdbsbd);,(dsdsds); NULL 
  </code></pre>
  
  <p>I don't want the comma in the address:</p>
  
  <pre><code>;,
  </code></pre>