我有一个名为table_B的表,其示例集如下:
+-serviceID-+-priceID-+-processOrder-+
| 001 | 003 | 03 |
+-----------+---------+--------------+
| 001 | 024 | 02 |
+-----------+---------+--------------+
| 001 | 001 | 01 |
+-----------+---------+--------------+
这是我的查询声明:
$query_string = '
SELECT services.*, GROUP_CONCAT(prices.priceID) AS priceID
FROM table_A AS services
INNER JOIN table_B AS prices ON services.serviceID = prices.serviceID
WHERE services.serviceID = "' . $serviceID . '"
GROUP BY prices.serviceID
LIMIT 1
';
$result = mysqli_query($link, $query_string);
$ row ['priceID']的结果是string(11) "001,003,024"
如何根据processOrder列在$ row ['priceID']中订购结果字符串?
我正在尝试将$ row ['priceID']作为string(11) "001,024,003"
答案 0 :(得分:2)
GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [,col_name ...]]
[SEPARATOR str_val])
您可以在括号内设置排序。