I have the following code:
SELECT * INTO OUTFILE'~/TestInput/Results.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FROM Results;
Desired results are to continually keep on appending to Results.csv
You can also use SELECT ... INTO OUTFILE with a VALUES statement to write values directly into a file. An example is shown here: SELECT * FROM (VALUES ROW(1,2,3),ROW(4,5,6),ROW(7,8,9)) AS t INTO OUTFILE '/tmp/select-values.
An append query selects records from one or more data sources and copies the selected records to an existing table. For example, suppose that you acquire a database that contains a table of potential new customers, and that you already have a table in your existing database that stores that kind of data.
The code is like this: LOAD DATA INFILE '/path/filename. csv' INTO TABLE table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' (column_name3, column_name5); Here you go with adding data to only two columns(you can choose them with the name of the column) to the table.
mysql> LOAD DATA LOCAL INFILE '/path/pet. txt' INTO TABLE pet; If you created the file on Windows with an editor that uses \r\n as a line terminator, you should use this statement instead: mysql> LOAD DATA LOCAL INFILE '/path/pet.
You can merge results and write at once. TEE will log everything which might not be desirable. In your case:
SELECT * FROM Results UNION
SELECT * FROM Results INTO OUTFILE '~/TestInput/Results.csv';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With