title: How to use INNER JOIN with array on second table in mysql?
body: <p>I can't properly use INNER JOIN. This is the actual return output via json on php.</p>
  
  <pre><code>[
      {
          "id": "1",
          "itinerary_customer_id": "856",
          "datetime_created": "2020-04-20 19:54:16",
          "documents": [
              {
                  "id": "1",
                  "itinerary_id": "1",
                  "datetime_created": "2020-04-20 22:51:12"
              },
              {
                  "id": "2",
                  "itinerary_id": "1",
                  "datetime_created": "2020-04-20 22:51:12"
              },
          ]
      },
      {
          "id": "2",
          "itinerary_customer_id": "857",
          "datetime_created": "2020-04-20 19:54:16",
          "documents": [
              {
                  "id": "3",
                  "itinerary_id": "2",
                  "datetime_created": "2020-04-20 22:51:12"
              },
              {
                  "id": "4",
                  "itinerary_id": "2",
                  "datetime_created": "2020-04-20 22:51:12"
              },
          ]
      }
  ]
  </code></pre>
  
  <p>Its look like array json and there's possible array inside each data.
  Here's my existing code.</p>
  
  <pre><code>$sql = "SELECT * FROM itinerary INNER JOIN itinerary_documents ON itinerary_documents.itinerary_id = itinerary.id WHERE itinerary_customer_id = '".$customer_id."' ";
      $result = $mysql-&gt;query($sql);
  
      if ($result-&gt;num_rows &gt; 0) {
          while ($row[] = $result-&gt;fetch_assoc()) {
              $item = $row;
              $json = json_encode($item);
          }
      }else{
          $item = array("error"=&gt; true, "message"=&gt; "No Itinerary found.");
          $json = json_encode($item);
      }
  
  echo $json;
  </code></pre>