MySQL query alias?
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 readin开发者_如何学编程g 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!
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
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.
精彩评论