Day: February 9, 2012

  • Importing a CSV file into a table in MySQL

    Here’s how you would import data into MySQL using a query /* If the CSV file was created in Windows, then replace ‘\n’ with ‘\r\n’ */ LOAD DATA LOCAL INFILE ‘/path/to/csv_file.csv’ INTO TABLE `table_name` FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY “\”” LINES TERMINATED BY ‘\n’ (field1, field2, field3);

  • Cool things you can do with MySQL

    Run a query from command line # Use the -e flag shell>mysql -e “select * from table” Tell MySQL to output the results of a query in HTML or XML # On command line you would write the following to # tell MySQL to output the results in HTML format shell>mysql -e “select * from…