23 lines
596 B
MySQL
23 lines
596 B
MySQL
|
|
CREATE OR REPLACE VIEW events_and_tablos
|
||
|
|
WITH (security_invoker)
|
||
|
|
AS
|
||
|
|
SELECT DISTINCT
|
||
|
|
e.id as event_id,
|
||
|
|
e.title,
|
||
|
|
e.start_date,
|
||
|
|
e.start_time,
|
||
|
|
e.end_time,
|
||
|
|
e.description,
|
||
|
|
t.id as tablo_id,
|
||
|
|
t.name as tablo_name,
|
||
|
|
t.color as tablo_color,
|
||
|
|
t.status as tablo_status
|
||
|
|
FROM events e
|
||
|
|
LEFT JOIN tablos t ON e.tablo_id = t.id
|
||
|
|
WHERE e.deleted_at IS NULL AND t.deleted_at IS NULL
|
||
|
|
ORDER BY e.start_date ASC, e.start_time ASC;
|
||
|
|
|
||
|
|
-- Add comment to document the view
|
||
|
|
COMMENT ON VIEW events_and_tablos IS
|
||
|
|
'View that returns all events and their associated tablos parameters';
|