Most posted solutions are wrong!!!
Ignore my post if you only interested in getting your code pass the leetcode test, but not interested in how to do things right!!!\n\n\nMost solutions posted he
**Ignore my post if you only interested in getting your code pass the leetcode test, but not interested in how to do things right!!!**\n\n\nMost solutions posted here have used \'count distinct product_key\'. However, this method **should NOT be considered as the correct answer**. For example, if the **Product** table contains **5 & 7** instead of **5 & 6**, using \'count distinct product_key\', you will still get results of customer_id **1 & 3**, which is definitely **WRONG!!!**\n\n![image](https://assets.leetcode.com/users/sophiesu0827/image_1576613740.png)\n\n**The correct procedures should be:**\n1. do a **cartesian product** (**cross join** in MySQL) on all customer_id eg.1,2,3 from table Customer and all product_key from table "Product ". \n![image](https://assets.leetcode.com/users/sophiesu0827/image_1576613877.png)\n\n\n2. find difference between table **Customer** and the **cartesian product**\n![image](https://assets.leetcode.com/users/sophiesu0827/image_1576613041.png)\n\n3. list all customer_id not in the difference set (red row in the above table)\n![image](https://assets.leetcode.com/users/sophiesu0827/image_1576614001.png)\n\n\n\n**MySQL code:**\n\n```\nSELECT DISTINCT customer_id FROM Customer WHERE customer_id NOT IN (\nSELECT customer_id FROM (\nSELECT DISTINCT * FROM \n(SELECT DISTINCT customer_id FROM Customer) C\nCROSS JOIN Product P) C2\nWHERE (customer_id,product_key) NOT IN (SELECT customer_id,product_key FROM Customer));\n```
[]