Due to the fact of the many fields asociated with a single company for some project (200+), I've have to change from a single row to 6 tables asociated with the main table through the id of the row of the main table...
FIRST: I'm not allowed to DELETE or UPDATE ANYTHING.
Each of the tables can be updated mutiples times...
Every time a record is updated, it is INSERT as a NEW record (with the ID of the main table)
Even the DELETE is a row in the status table because it is not really deleted and can be undone with another record where status change again to 'live'.
So, for every table, you have a history of all the changes made, where were made, who made them and can see them one by one.
How can I SELECT a single RECORD from ALL tables at the same time?
The right ones should be the LAST ONES INSERTED IN EACH TABLE.
In other words, it should be something like mergin all of this
Some clue?
Now I'm making 7+ selects for showing ONE page and I want to reduce it to only ONE select.
I don't mind if I have to change the database for another schema if you have a better way, but I repeat: I'M NOT ALLOWED TO OVERWRITE ANYTHING.
FIRST: I'm not allowed to DELETE or UPDATE ANYTHING.
Each of the tables can be updated mutiples times...
Every time a record is updated, it is INSERT as a NEW record (with the ID of the main table)
Even the DELETE is a row in the status table because it is not really deleted and can be undone with another record where status change again to 'live'.
So, for every table, you have a history of all the changes made, where were made, who made them and can see them one by one.
How can I SELECT a single RECORD from ALL tables at the same time?
The right ones should be the LAST ONES INSERTED IN EACH TABLE.
In other words, it should be something like mergin all of this
Code:
SELECT * FROM TABLE1 where idp=999 + select * from TABLE2 where idp=999 ORDER BY idp DESC limit 1 + select * from TABLE3 where idp=999 ORDER BY idp DESC limit 1 + select * from TABLE4 where idp=999 ORDER BY idp DESC limit 1 + select * from TABLE5 where idp=999 ORDER BY idp DESC limit 1 + select * from TABLE6 where idp=999 ORDER BY idp DESC limit 1
Now I'm making 7+ selects for showing ONE page and I want to reduce it to only ONE select.
I don't mind if I have to change the database for another schema if you have a better way, but I repeat: I'M NOT ALLOWED TO OVERWRITE ANYTHING.
Comment