January 17th, 2013, 12:38 PM
I have a select statement that looks like this:
SELECT authorid, trim(lastname) || ', ' || trim(firstname) as authorname FROM authors ORDER BY authorname;
but it's cumbersome. I would rather just do:
SELECT authorid, authorname FROM authors ORDER BY authorname;
but I don't want to maintain the authorname column in the database with a trigger that updates it any time lastname or firstname is changed. Does PostgreSQL have macros?
January 17th, 2013, 04:04 PM
Create a VIEW: http://www.postgresql.org/docs/current/static/tutorial-views.html
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions:
January 19th, 2013, 11:33 AM
Thanks, this is exactly what I want.