title: Create mysql view from 2 tables with should match on first table column value and second table column value
body: <p><img src="https://i.stack.imgur.com/PODh7.png" alt="Table 1" /></p>
  <p><img src="https://i.stack.imgur.com/t7Dgy.png" alt="Table 2" /></p>
  <p>Hi,
  I have two WordPress tables using which I am trying to generate a new view. Now how to make sure the new view I am generating has a value that matches with first table column value and second table column value.</p>
  <p>For example, I want to generate a view where the entry_id of table 1 matches with id of table 2 and
  the value of meta_key 4.3 should be equal to '' in table 1 and payment_status='Paid' in table 2</p>
  <p>Generate Below view where Meta_value='Ind_City_1_Loc_1' in table 1 and payment payment status = 'paid' in table 2.
  <img src="https://i.stack.imgur.com/j7oOH.png" alt="Table 3" /></p>
  <pre><code>SELECT 
      MAX(CASE
          WHEN p.meta_key = 'given_transaction_id' THEN p.meta_value
          ELSE NULL
      END) AS 'TransactionID',
      MAX(CASE
          WHEN p.meta_key = '17' THEN p.meta_value
          ELSE '1'
      END) AS 'Quantity',
      MAX(CASE
          WHEN p.meta_key = '7.3' THEN p.meta_value
          ELSE NULL
      END) AS 'First Name',
      MAX(CASE
          WHEN p.meta_key = '7.6' THEN p.meta_value
          ELSE NULL
      END) AS 'Last Name',
      MAX(CASE
          WHEN p.meta_key = '8' THEN p.meta_value
          ELSE NULL
      END) AS 'Email',
      MAX(CASE
          WHEN p.meta_key = '9' THEN p.meta_value
          ELSE NULL
      END) AS 'Contact',
      MAX(CASE
          WHEN p.meta_key = '20.3' THEN p.meta_value
          ELSE NULL
      END) AS 'Member 1',
      MAX(CASE
          WHEN p.meta_key = '27.3' THEN p.meta_value
          ELSE NULL
      END) AS 'Member 2',
      MAX(CASE
          WHEN p.meta_key = '34.3' THEN p.meta_value
          ELSE NULL
      END) AS 'Member 3',
      MAX(CASE
          WHEN p.meta_key = '41.3' THEN p.meta_value
          ELSE NULL
      END) AS 'Member 4',
      MAX(CASE
          WHEN p.meta_key = '48.3' THEN p.meta_value
          ELSE NULL
      END) AS 'Member 5'
  FROM
      pday_gf_entry_meta AS p,
      pday_gf_entry AS pm
  WHERE
      (p.entry_id = pm.id AND p.form_id = '12')
  GROUP BY p.entry_id
  </code></pre>