title: How to create a view including the following tables?
body: <p>I have the following <code>2 tables involved</code>, I am trying to <code>create a view popularProducts</code>, where the <code>sum of each product's quantityOrdered</code> are equal or above 100. </p>
  
  <p>I tried the following but it does't quite looks right to me: </p>
  
  <pre><code>SELECT productCode, productName, buyPrice, image FROM products JOIN orderDetails on products.productCode=orderDetails.products_productCode WHERE (SELECT SUM(quantityOrdered) &gt;= 100);
  </code></pre>
  
  <p><code>OrderDetails</code> table:</p>
  
  <pre><code>CREATE TABLE `orderDetails` (
    `products_productCode` bigint(20) UNSIGNED NOT NULL,
    `orders_orderNumber` bigint(20) UNSIGNED NOT NULL,
    `quantityOrdered` varchar(45) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>And <code>products</code> table: </p>
  
  <pre><code>CREATE TABLE `products` (
    `productCode` bigint(20) UNSIGNED NOT NULL,
    `productName` varchar(45) DEFAULT NULL,
    `productDescription` text,
    `quantityInStock` smallint(5) UNSIGNED DEFAULT NULL,
    `buyPrice` decimal(7,2) UNSIGNED DEFAULT NULL,
    `image` varchar(45) DEFAULT NULL
  ) E
  </code></pre>