我有一个疑问:
<?php
$results = $dbConn->select("SELECT entryA, entryB FROM table");
/**
Displays the rows on $results (entryA, entryB)
1 7
8 5
4 3
5 8
7 1
3 4
**/
$results = $dbConn->select("SELECT entryA, entryB FROM table ORDER BY ?");
/**
The correct output must be: (entryA, entryB)
1 7
7 1
8 5
5 8
4 3
**/
?>
如何在不同的行中对彼此相等/匹配的两列 id 进行排序?
提前谢谢。
是的。例如
SELECT entryA, entryB FROM table ORDER BY entryA*entryA+entryB*entryB
-在我的样本中,我假设您有两个对变体,即{1,7}
和{7,1}
,例如。
这将独立于元素顺序对相同的对进行分组,但您可能希望有额外的顺序条件 - 然后只需将其添加到ORDER BY
子句中