我有两张表,一张是价格优先级表,另一张是分钟数优先级表,每个用户和产品都有对应的记录。如何选择它们以便对于每个用户和产品都有一个记录呢?
Table 1: Override Prices
+--------+-----------+---------------+
| userID | productID | overridePrice |
+--------+-----------+---------------+
| 4 | 53 | 99.99 |
| 4 | 13 | 99.99 |
| 4 | 55 | 99.99 |
+--------+-----------+---------------+
Table 2: Override Minutes
+--------+-----------+---------------+
| userID | productID | overrideMin |
+--------+-----------+---------------+
| 4 | 18 | 23 |
| 4 | 55 | 4 |
| 50 | 55 | 2 |
+--------+-----------+---------------+
我希望您能够生成我需要的表格。
Table 2: All overrides
+--------+-----------+-------------+---------------+
| userID | productID | overrideMin | overridePrice |
+--------+-----------+-------------+---------------+
| 4 | 13 | null | 99.99 |
| 4 | 18 | 23 | null |
| 4 | 53 | null | 99.99 |
| 4 | 55 | 4 | 99.99 |
| 50 | 55 | 2 | null |
+--------+-----------+-------------+---------------+
我尝试按userID
和productID
进行分组,但是由于表1中可能存在表2中不存在的产品ID,所以根据我分组的productID
不同会得到不同的结果。