[英]ordering two columns php mysql
我有一个查询:
<?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
子句中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.