How to split one row in the table for a few?

For example, there is a record in the database
table work_times
id: 1
date: 20.08.2020
time_start: 14:00
time_end: 18:00

And table order
orders
date: 20.08.2020
time_start: 16:00
time_end: 17:00

I need to make a query that will give
date: 20.08.2020
time_start: 14:00
time_end: 16:00

date: 20.08.2020
time_start: 17:00
time_end: 18:00
March 23rd 20 at 19:10
1 answer
March 23rd 20 at 19:12
The question is not quite understand, but if you mean display the data from both tables (no join), you can use a UNION (SELECT x,y,z FROM table1 UNION SELECT x1,y1,z1 FROM table2). Then you can top ORDER to set up.
Well, if you meant rows interchanged with columns, it is the PIVOT operator. - Obie_McLaughlin commented on March 23rd 20 at 19:15
@Obie_McLaughlin, meant to make a select statement which would be issued instead of one row in the table for two. Given the fact that part-time working busy ordering - Russel.Howell85 commented on March 23rd 20 at 19:18
@Russel.Howell85, But some kind of link between the tables? (ID?)
If not, then is the time work item inside the order? (or Vice versa).
I.e. if there is an ID, it is trivial join

SELECT wi.date, wi.start wi.end, o.start, o.end
FROM work_items AS wi
JOIN orders AS o ON o.ID = wi.Orders_ID

over time, more complicated, but the same pattern approximately (if one interval is included into another if 1 order a day (or 1 work item per day)). - Obie_McLaughlin commented on March 23rd 20 at 19:21
@Obie_McLaughlin, no communication), only the date - Russel.Howell85 commented on March 23rd 20 at 19:24
@Russel.Howell85, OK, date. what is the rule? - Obie_McLaughlin commented on March 23rd 20 at 19:27
@Obie_McLaughlin, thanks for the help, came up with the ka to solve it

first make a selection work_times.start union orders.end as start . And join c work_times.end union orders.start - Russel.Howell85 commented on March 23rd 20 at 19:30

Find more questions by tags SQLPostgreSQL