我有几张table想拼在一起。
第一个脚本如下
SELECT
Project_Assignment.ID_Project,
MIN(Project_Assignment.ID_Workstep) as orderme // this field i removed for mysql field() function
FROM
ProjectBoard.Project_Assignment
WHERE
Project_Assignment.isDone = 0
GROUP BY Project_Assignment.ID_Project
ORDER BY MIN(Project_Assignment.ID_Workstep)
它又回来了
| ID_Project | orderme |
| 12 | 1 |
| 8 | 2 |
| 11 | 4 |
| 16 | 9 |
我的第二个问题是
SELECT
Workstep_Content.ID_Project,
Workstep_Content.ID_Step,
Workstep_Content.Content
FROM
ProjectBoard.Workstep_Content
返回
| ID_Project | ID_Step | Content |
| 11 | 11 | one |
| 11 | 12 |another one |
| 12 | 1 | two |
| 8 | 11 | this |
| 16 | 1 | first |
| 16 | 4 | second |
现在我想按照第一个查询中ID_Project的顺序对第二个查询的结果进行排序。结果应该如下所示:
| ID_Project | ID_Step | Content |
| 12 | 1 | two |
| 8 | 11 | this |
| 11 | 11 | one |
| 11 | 12 |another one |
| 16 | 1 | first |
| 16 | 4 | second |
我尝试在ORDER BY子句中使用MySQL FIELD函数,但它无法正常工作(ORDER BY FIELD(ID_Project,first_query)
2条答案
按热度按时间py49o6xq1#
与子查询连接,然后使用
ORDER by orderme
ymdaylpp2#
我会怎么做...
别人怎么做...
无政府主义者是如何做到的...