CREATE VIEW active_users AS
SELECT id, name, email
FROM users
WHERE status = 'active' AND deleted_at IS NULL;
-- use it like a table
SELECT * FROM active_users WHERE email LIKE '%@gmail.com';Views simplify code and hide complexity. But nested views (a view on a view) can be hard for the optimiser to handle. In MySQL, views do not always use indexes efficiently.