假设我有两个表,table1,有两个字段:id 和 cost,在 (cost, id)上有一个聚集的主索引强>.另一个表 table2 只有 id,这是主键。
因此,由于聚簇索引,table1 中的数据按成本排序。
如果我去:
Select * from table1 join table2 using (id)
结果并不总是按照表 1 中聚集索引定义的顺序排列。在那种情况下,当将多个表连接到具有特定/复合聚集索引的表时,如何实现这种排序?
最佳答案
您正在寻找的是 STRAIGHT_JOIN。
如果你这样做:
SELECT * from table1 STRIAGHT_JOIN table2 using (id)
订单将被保留。
关于php - 如何实现MySQL Clustered Index-Ordered Join Result,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42187799/