title: Selecting different columns from 3 tables
body: <p>Before asking, i just want to tell you that i am looking solution for my problem since 1 week, i tried many times to solve my problem myself but failed.</p>
  <p>I have 3 different tables tables</p>
  <ol>
  <li>users</li>
  <li>wallet_transactions</li>
  <li>wallet_payment</li>
  </ol>
  <p>I want to get combine results from these tables.I tried <strong>join</strong> method of sql and get some result but no required.</p>
  <p><strong>Here is my USER table</strong></p>
  <pre><code>     userId  User_name           Wallet
         1    Abdulrehmanahmad      1107.5
         2    Azzhar789             1089
         3    azharmehmood          1022
         4    komalali              1252
         5    Muhammadbasheer        800
         
  </code></pre>
  <p><strong>2: <strong>Table is wallet_transactions</strong></strong>  (Data of Withdrwal request sent)</p>
  <pre><code>    Transaction_id    user_id   Node_type           amount    type(in/out)     date
            1             3      withdrawal_wallet      1022       out          2022-07-22 
            2             2      withdrawal_wallet      1089       out          2022-07-22              
            3             4      withdrawal_wallet      400        out          2022-07-22
            4             4      withdrawal_wallet      452       out           2022-07-22
            5             4      withdrawal_wallet      400       out           2022-07-21
  </code></pre>
  <p><strong>3: Table is wallet_payment</strong></p>
  <p>(status 1 is for withdrawal accepted , -1 is for rejected , 0 for pending)</p>
  <pre><code>         user_id     amount        time        status
              3         1022      2022-07-23        1
              2         1089      2022-07-23        0
              4          400      2022-07-23        -1
              4          452      2022-07-23        1
              4          400      2022-07-22        1
  </code></pre>
  <p>I want to get result from these tables like this.</p>
  <pre><code>            sr  user_name   Latest_Withdrawal       Time
               1  Komalali        400           3 hours ago
               2  komalali        452           8 hours ago
               3  Sadiakhan       250           1 day ago
               4  Fidakhan211     380           1 day ago
               5  alifk1218       481           1 day ago
  </code></pre>
  <p>Here is a code that i use for get this result</p>
  <pre><code>  SELECT users.user_name , wallet_transactions.amount ,wallet_transactions.date, 
    wallet_payments.time from users 
    INNER JOIN wallet_transactions  ON  users.user_id=wallet_transactions.user_id
    INNER JOIN wallet_payments ON wallet_payments.user_id=wallet_transactions.user_id
    where wallet_transactions.node_type ='withdraw_wallet' &amp;&amp; 
    wallet_transactions.type='out' &amp;&amp; wallet_payments.status=1
    GROUP BY wallet_payments.time 
    ORDER BY wallet_payments.time desc ;
  </code></pre>
  <p>And this query gives me like this result.</p>
  <pre><code>  ID    XD USERS    Latest Withdrawal   Time
     1    komalali         400          2022-08-16 17:16:00
     2    komalali         400          2022-08-16 17:09:38
     3    Sadiakhan        250          2022-08-15 17:23:36
     4    Fidakhan211      380          2022-08-15 10:23:06
     5    alifk1218        481          2022-08-15 07:30:01
  </code></pre>