I want to make a linked table information from 3 tables. This table will be sorted by date (day / month / year Hours: Minutes) and visually speaking would look like this
For better understanding I will post the structure of the banks
table: realation_notes
id user_id comments comment_date
table: historic_attendance
id user_id date contact_p contact_e contact_t contact_w contact_m
table: clients_documents
id user_id file_name attachment date
I initially thought about using a UNION getting more or less like this
(SELECT id, user_id, comments, comment_date AS date FROM 'realation_notes'
WHERE 'user_id' = 582)
UNION
(SELECT * FROM 'historic_attendance' WHERE 'user_id' = 582)
UNION
(SELECT * FROM 'clients_documents' WHERE 'user_id' = 582)
ORDER BY date
but this SQL returns me the following error:
Os comandos SELECT usados têm diferente número de colunas
How could I circumvent this problem?