我有两张桌子:
project.sql
projectNo| title |
---------+-------+
17020002 | test |
17020003 | test2 |
process.sql
projectNo| process |
---------+---------+
17020002 | ANM |
17020002 | BLD |
17020003 | ANM KEY |
17020003 | BLD |
有没有办法从mysql查询创建html表,如下所示:
| |
+---------+
| test |
| ANM |
| BLD |
| test2 |
| ANM KEY |
| BLD |
我尝试的是使用UNION ALL,但它没有给我预期的结果:
SELECT title FROM project p1
UNION ALL
SELECT process FROM process p2
答案 0 :(得分:2)
使用固定列对结果进行排序,请尝试以下操作:
SELECT title
FROM (
SELECT projectNo, title, 0 AS a FROM project p1
UNION ALL
SELECT projectNo, process, 1 AS a FROM process p2) t
ORDER BY projectNo, a, title