title: How to get data from another table using sql query?
body: <p>I have 2 MySQL tables which are below : </p>
  
  <p><strong>users</strong> table (<code>st_id</code> is station table primary key)</p>
  
  <pre><code>uid  fname  lname company_name  email    phone  st_id
  =====================================================
  9    xxx    yyyy  zzzz          x@y.com  xxx    5,6
  </code></pre>
  
  <p><strong>station</strong> table</p>
  
  <pre><code>st_id  uid   st_name  st_lat  st_long  lg_id
  ============================================
  5      9     xxx      24.25   24.95    8,9,10
  6      9     yyy      23.25   23.95    11,12,12
  </code></pre>
  
  <p>Now using <strong>one</strong> SQL query I want to get all data from <code>users</code> table and all <code>st_name</code> from <code>station</code> table which <code>st_id</code> is match with <code>uid</code></p>
  
  <p>That's mean it's should return all data from <code>users</code> table and all <code>st_name</code> from <code>station</code> table which <code>uid</code> = 9 </p>
  
  <p><strong>My current SQL query :</strong> </p>
  
  <pre><code>$getData = mysqli_query($conn, "SELECT users.uid, users.company_name, users.fname, users.lname, users.phone, users.email, station.st_id, station.st_name, logger.lg_name FROM users 
  LEFT JOIN station ON station.st_id = users.st_id 
  LEFT JOIN logger ON logger.lg_id = station.lg_id 
  LEFT JOIN channel ON channel.ch_id = logger.ch_id  
  WHERE users.power != 'admin' ");
  </code></pre>
  
  <p><strong>Note:</strong> In <code>station</code> table I stored <code>st_id</code> values as array. Like : </p>
  
  <pre><code>$st_id_value =  implode(',', $st_id_value); 
  </code></pre>
  
  <p><strong>Update Code :</strong> </p>
  
  <pre><code> $getData = mysqli_query($conn, "SELECT users.uid, users.company_name, users.fname, users.lname, users.phone, users.email, station.st_id, station.st_name, logger.lg_name 
  FROM users LEFT JOIN station
  ON FIND_IN_SET(station.st_id, users.st_id)
  LEFT JOIN logger ON logger.lg_id = station.lg_id 
  LEFT JOIN channel ON channel.ch_id = logger.ch_id
  WHERE users.power != 'admin' AND station.uid=$uid");
  
  $fetchData = mysqli_fetch_assoc($getData) ;
  
  echo '&lt;pre&gt;';
      print_r($fetchData);
  echo '&lt;/pre&gt;'; 
  </code></pre>
  
  <p><strong>Return :</strong> </p>
  
  <pre><code>Array
  (
      [uid] =&gt; 9
      [company_name] =&gt; Source and Services
      [fname] =&gt; azad
      [lname] =&gt; ahmed
      [phone] =&gt; 01671133639
      [email] =&gt; azad@gmail.com
      [st_id] =&gt; 5
      [st_name] =&gt; Rajshahi
      [lg_name] =&gt; D4L08841
  )
  </code></pre>