VirtualMV/MySQL/Interactive Help Desk

Instructions
On this page you can post some MySQL code that you are having trouble with.
 * Please keep the code "simple" concentrating on the problem ... not a lot of code with a "small" problem.
 * Post a tweet including the #vmvwiki tag so that we know there is a problem waiting to be solved.
 * Paste the following wiki code when you edit, and put your code where shown.

Posting reward scheme
The rules here are:
 * if it is a complex problem, and you solve it you should be rewarded with a small choc from the person posting, however
 * if it is easy to solve a more substantial chocolate "gift" (like a large chocolate fish would be nice :)

Problem 1: UPDATE not working
one.sql

This causes a MySQL Error...

Problem 2: Code looks ok, but MySQL flags errors
Problem: If your code throws errors and you have cut & pasted from another place it may have brought across special characters (like tab) that MySQL struggles with

Solution 1: Check that the filename & path are spelt correctly!

Solution 2: You may need to retype the code. Note: You may find clues if you look at the actual code when pasted into MySQL.

Solution 3: Check ";" are correct or "," in create statements.

Solution 4: If in Select check the order of conditions

Solution 6: Check that you have not used Create Database dbDatabaseCruise i.e. is "database" necessary.

Solution 7: It maybe compressing tabs (you can see it if things that should be separate are joined when displayed in mySQL e.g. tradeNamevarchar(40). In Notepad++ open the file, on the menu choose Edit > Blank Operations > TAB to Space.

Problem 3: SOURCE
If SOURCE h://prog1.sql gives an error 2 (not found) try moving to drive C

e.g. SOURCE c://prog1.sql

Seems that Windows has some file protections.

Problem 4: CSV Files
CSV or comma delimited files can be used to add data to a table. For example you can create a spreadsheet and put all the data in. You then export to a ".csv" file.

For importing a file you may need to use

lines terminated by '\r\n'\

As this is the way windows saves text files.

Ref: https://stackoverflow.com/questions/22622842/replace-n-r-in-mysql-database