title: List Customer And Product Without Sale
body: <p>Need to show the following columns (3) using UNION to return:</p>
  <ul>
  <li>All customers who do not have an invoice</li>
  <li>All products that were not sold</li>
  </ul>
  <ol>
  <li>Category: Is this related to &quot;customer&quot; or &quot;product&quot;? Print &quot;customer or &quot;product&quot;</li>
  <li>ID: Customer.id (category=&quot;customer&quot;) or product.id (category=&quot;product&quot;)</li>
  <li>Name: customer.customer_name (category=&quot;customer&quot;) or product.product_name (category=&quot;product&quot;)</li>
  </ol>
  <p><em>Tables:</em></p>
  <p><em>Customer</em></p>
  <ul>
  <li>id</li>
  <li>customer_name</li>
  <li>city_id</li>
  <li>customer_address</li>
  <li>contact_person</li>
  <li>email</li>
  <li>phone</li>
  </ul>
  <p><em>Product</em></p>
  <ul>
  <li>id</li>
  <li>sku</li>
  <li>product_name</li>
  <li>product_description</li>
  <li>current_price</li>
  <li>quantity_in_stock</li>
  </ul>
  <p><em>Invoice</em></p>
  <ul>
  <li>id</li>
  <li>invoice_number</li>
  <li>customer_id</li>
  <li>user_account_id</li>
  <li>total_price</li>
  <li>time_issued</li>
  <li>time_due</li>
  <li>time_paid</li>
  <li>time_canceled</li>
  <li>time_refunded</li>
  </ul>
  <p><em>Invoice_Item</em></p>
  <ul>
  <li>id</li>
  <li>invoice_id</li>
  <li>product_id</li>
  <li>quantity</li>
  <li>price</li>
  <li>line_total_price</li>
  </ul>
  <p>So far have the following:</p>
  <pre><code>SELECT 
    category,
    CASE
        WHEN category = 'customer' THEN c.id
        WHEN category = 'product' THEN p.id
    END AS 'id',
    CASE
      WHEN category = 'customer' THEN c.customer_name
      WHEN category = 'product' THEN p.product_name
    END AS 'name'
  FROM 
    (
      SELECT
          CASE
            WHEN c.id = c.id THEN 'customer'
            WHEN p.id = p.id THEN 'product'
          END as 'category'
      FROM
          customer as c
      LEFT Join -- Left join to show all customers even those with &amp; without invoices
          invoice as i
      ON c.id = i.customer_id
      AND i.id IS NULL -- Gives me all customers who do not have an invoice
      JOIN invoice_item as ii
      ON i.id = ii.invoice_id
      Join product p
      ON p.id = ii.product_id
    ) tb1
  
  UNION ALL
  
  SELECT 
    category,
    CASE
        WHEN category = 'customer' THEN c.id
        WHEN category = 'product' THEN p.id
    END AS 'id',
    CASE
      WHEN category = 'customer' THEN c.customer_name
      WHEN category = 'product' THEN p.product_name
    END AS 'name'
  FROM
    (
      SELECT 
        CASE
          WHEN c.id = c.id THEN 'customer'
          WHEN p.id = p.id THEN 'product'
        END as 'category'
      FROM
          product as p
      LEFT JOIN -- Left join to show all products even those that sold and not sold
          invoice_item as ii
      ON p.id = ii.product_id
      AND ii.invoice_id IS NULL -- Gives me products that didnt sell
      JOIN invoice as i
      ON ii.invoice_id = i.id
    ) tb2
  </code></pre>
  <p>Open to any suggestions as I'm stuck trying to figure out how to show the category as either &quot;product&quot; or &quot;customer&quot;. Thanks in advance!</p>