Reputation: 5028
So I have created a view and want to display new columns of the view with new names, for instance:
CREATE VIEW monthly_view AS
(SELECT co.object_id, co.object_alias, cm.method_alias, dr.data_value,
cd.data_uom, dr.date_timestamp, dr.delay_value, dr.delay_pct
FROM data_realtime AS dr
JOIN chroniker_object AS co ON co.object_id=dr.object_id
JOIN chroniker_data AS cd ON cd.data_id=dr.data_id
JOIN chroniker_method AS cm ON cm.method_id=co.method_id)
What i want is whenever "monthly_view" is displayed, the "co.object_id" can be shows as "Object".
Thanks
Upvotes: 1
Views: 51
Reputation: 1841
Have you tried giving aliases in select statement?
CREATE VIEW monthly_view AS
(SELECT co.object_id AS Object,
co.object_alias AS ObjectAlias,
....
FROM data_realtime AS dr
JOIN chroniker_object AS co ON co.object_id=dr.object_id
JOIN chroniker_data AS cd ON cd.data_id=dr.data_id
JOIN chroniker_method AS cm ON cm.method_id=co.method_id)
Upvotes: 0
Reputation: 49079
You can use an alias:
CREATE VIEW monthly_view AS
SELECT co.object_id AS Object,
co.object_alias AS ...,
cm.method_alias AS ...,
...
FROM
...
Upvotes: 2