From 8082c08244bce44b9426c17c85a0b84024b3be78 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 13 Nov 2023 19:55:36 +0700 Subject: [PATCH] Create SQL.sql --- SQL.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 SQL.sql diff --git a/SQL.sql b/SQL.sql new file mode 100644 index 0000000..8aa376a --- /dev/null +++ b/SQL.sql @@ -0,0 +1,16 @@ +#Get S-P Access +USE face_detect; + +-- Get Student Access +SELECT `access-log`.id , `students`.name as `student_name`, `parents`.name as `parents_name`, `access-log`.`timestamp` +FROM face_detect.`access-log` +JOIN parents ON `access-log`.parent_id = `parents`.id +JOIN students ON `access-log`.student_id = `students`.id +ORDER BY `access-log`.`timestamp` ASC; + +-- Get Parents Accesses +SELECT `access-log`.id, `parents`.name as `parents_name`, `access-log`.`timestamp` +FROM face_detect.`access-log` +JOIN parents ON `access-log`.parent_id = `parents`.id +WHERE `access-log`.student_id IS NULL +ORDER BY `access-log`.`timestamp` ASC;