How to create a MySQL query alias?

For example, I use this

select * from tab1;

every 5 minutes.

Is there a way to set up an alias pso that I can just do

p

and this request is fulfilled?

+3
source share
4 answers

This calls view , but in your case it is not much shorter: create view p as selecT * From tab1;
you would use it like:select * from p

However, it becomes more interesting with more complex queries.

+3
source

You can create a stored procedure and then call it as CALL p.

http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html

+2
source

. , :

CALL p;

:

CREATE PROCEDURE p() SELECT * FROM tab1;
+1

p

   call p
0
source

Source: https://habr.com/ru/post/1756698/


All Articles