我有这张桌子
select id, name from projects;
id | name
---+-------------
1 | TestProject
2 | testProject
3 | test
4 | sdaf
5 | P0500
和此表(work_packages)
select * from work_packages;
id | name | started_on | finished_on | person_month | parent_id | project_id
----+---------+------------+-------------+--------------+-----------+------------+---------
7 | AP00001 | 2015-10-23 | 2015-10-31 | 0 | 1 | 1 |
8 | d | 2015-10-23 | 2015-10-31 | 0 | 7 | 1 |
我需要projects
和work_packages
name
---------------
P0500
AP00001
d
答案 0 :(得分:0)
尝试:
select name from projects
union
select name from work_packages;
您可以在条件中过滤结果,例如
select name from projects
where id >= 5
union
select name from work_packages;