1. CREATE [ORREPLACE] [lt; algorithmattributesgt;] VIEW [database.] lt; namegt; [(lt; columnsgt;)] ASlt; selec
1. CREATE [or replace] [lt; algorithm attributesgt;] VIEW [database.] lt; namegt; [(lt; columnsgt;)] AS lt; selec
1. Create
CREATE [or replace] [] VIEW [database.] <name> [( )]
AS []Example:Create view 'view _ articles'ASSELECTA. id AS id,A. title AS title,A. content AS content,T. name AS tagname,U. firstname AS "username"FROM 'articles'aLeft join 'tags' tON a. tag_id = t. idLeft join 'users' uON a. user_id = u. idOrder by a. posttime DESC;ModifyALTER [] VIEW [.] <Name> [()]AS[ ]
Example:
Alter view 'view _ articles'
AS
SELECT
A. id AS id,
A. title AS title,
A. content AS content,
A. posttime AS posttime,
T. name AS tagname,
CONCAT (u. firstname, '', u. lastname) AS" username"
FROM 'articles'a
Left join 'tags' t
ON a. tag_id = t. id
Left join 'users' u
ON a. user_id = u. id
Order by a. posttime DESC;
The easiest way to modify a created visual chart is to export the SQL statement of the visual chart in phpMyAdmin, then modify the "CREATE" at the beginning (the "ALGORITHM = undefined definer = 'root' @ 'localhost' SQL SECURITY DEFINER" at the end) to "ALTER ", run the statement.
,