tags:

views:

28

answers:

2

I was reading something a few months ago that would take something like:

SELECT first, last FROM contacts where status = 'active'

and turn it into:

SELECT first, last FROM active_contacts

It's definitely not a stored procedure and I'm pretty sure it's not a prepared statement. I'm also positive what I was reading did not involve temporary tables or anything like that. It was something that didn't modify or move the data in any way.

Thanks in advance!

+2  A: 

You are talking about views.

You can create a view as:

CREATE VIEW  active_contacts AS 
SELECT first, last 
FROM contacts 
WHERE status = 'active'

then use it as:

SELECT first, last FROM active_contacts
codaddict
Thank you so much!
Stephane
A: 

I think it must be view. The view would be defined in terms of a query, in this case:

SELECT * from contacts where status = 'active'

The view is given a name active_contacts and can be referenced by this name as if it were a table.

Andrew Cooper