I have this table
select id, name from projects;
id | name
---+-------------
1 | TestProject
2 | testProject
3 | test
4 | sdaf
5 | P0500
and this table (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 |
I need this table from projects
and work_packages
name
---------------
P0500
AP00001
d
Try:
select name from projects
union
select name from work_packages;
You can filter the result in where condition, eg
select name from projects
where id >= 5
union
select name from work_packages;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.