I have several tables with a bunch of fields and I need a Query that includes ALL the fields from two tables (JOINs). The result should have consistent naming scheme for the fields, that survives when I add fields to the source table.
To always select all fields of a table I can use the * operator. But when I join two tables using the *, it prepends the fields that occur in both tables (and only those) with the table name.
SELECT kids.*, parents.* FROM parents INNER JOIN kids ON parents.ID = kids.ParentID;
gives me
kids.name, birthday, school, parents.name, address ...
When I add a birthday column to the parents table I get
kids.name, kids.birthday, school, parents.name, parents.birthday, address ...
And I have to update birthday
to kids.birthday
everywhere.
Is there a way to prepend all column names in the beginning? So I'd get
kids.name, kids.birthday, kids.school, parents.name, parents.address ...
in the first place?