0

I would like to create something like a query that gets called everytime I write an alias. So something like :

myalias = select codes from codetables where validity=current_date ;

then use it like :

select * from mainregistry where code in (myalias) ;

the "myalias" should be available everywhere everytime, so there should be a way of having it "default" in all my dbs.

1 Answer 1

2

It's called a view:

CREATE VIEW myalias AS
SELECT codes
FROM codetables
WHERE validity=current_date;

and then:

SELECT * FROM mainregistry
WHERE code IN (SELECT codes FROM myalias);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.