I have this tables in mysql:
students time class_student
someone 1 something01
someone 2 something02
someone 3 something03
someone 4 something04
someone 5 something05
theachers time class_teachers
someone 1 something11
someone 3 something12
someone 5 something13
someone 7 something14
someone 9 something15
someone 11 something16
and I need to get the class filds form each table order by all time in both tables, like this
time class_student class_teachers
1 something01 something11
2 something02
3 something03 something12
4 something04
5 something05 something13
7 something14
9 something15
11 something16
first I test this query that the result is al times in both tables
SELECT time FROM table1
UNION
SELECT time FROM table2
ORDER BY time
I have this query that return the data but in the same fild
SELECT class_student FROM table1 WHERE time IN (
SELECT time FROM table2
UNION
SELECT time FROM table1
ORDER BY time
)
UNION
SELECT class_teachers FROM table2 WHERE time IN (
SELECT time FROM table2
UNION
SELECT time FROM table1
ORDER BY time
);
and I try this one, but the sql doesn't execute it
SELECT
class_student,
class_teachers
FROM
table1
inner join
table2 on time IN (
SELECT time FROM table1
UNION
SELECT time FROM table2
ORDER BY time
);