我有三张桌子:
(域)
+----+-----+
| id |title|
+----+-----+
| 1 | com |
+----+-----+
| 2 | net |
+----+-----+
(板)
+----+-----+
| id |title|
+----+-----+
| 1 |str1 |
+----+-----+
| 2 |str2 |
+----+-----+
(价格)
+----+------+--------+
| id |slabid|domainId|
+----+------+--------+
empty
这是我的查询:
SELECT
prices.*,
FROM
prices
RIGHT JOIN domains ON domains.id=prices.domainId
JOIN slabs ON slabs.id=prices.slabId
我应该如何让查询按域和平板行列出...
结果应该是这样的:
+----+------+--------+
| id |slabid|domainId|
+----+------+--------+
| 1 |1 |1 |
+----+------+--------+
| 2 |2 |1 |
+----+------+--------+
| 3 |1 |2 |
+----+------+--------+
| 4 |2 |2 |
+----+------+--------+
但事实并非如此。