From b535e00282f6d91b3492f556f82779d3315de60c Mon Sep 17 00:00:00 2001 From: Robert Edward <32665236+Bobby00@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:46:19 +0300 Subject: [PATCH] MySQL Dump by Query --- .../mysql-dump-by-query/mysql-dump-by-query.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sql-queries-5/mysql-dump-by-query/mysql-dump-by-query.sql diff --git a/sql-queries-5/mysql-dump-by-query/mysql-dump-by-query.sql b/sql-queries-5/mysql-dump-by-query/mysql-dump-by-query.sql new file mode 100644 index 00000000..a135499d --- /dev/null +++ b/sql-queries-5/mysql-dump-by-query/mysql-dump-by-query.sql @@ -0,0 +1,15 @@ +-- Using temporary table and mysqldump +CREATE TEMPORARY TABLE september_enrollments AS +SELECT * FROM Student +WHERE enrollment_date >= '2024-09-01' +AND enrollment_date <= '2024-09-30'; + + +-- Using SELECT INTO OUTFILE Statement +SELECT * FROM Student +WHERE enrollment_date >= '2024-09-01' +AND enrollment_date <= '2024-09-30' +INTO OUTFILE '/path/to/september_enrollements.csv' +FIELDS TERMINATED BY ',' +ENCLOSED BY '"' +LINES TERMINATED BY '\n';