VirtualMV/MySQL/Interactive Help Desk
Home Help Desk, MySQL < |
Table of contents |
---|
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.
{{vmv:Source|<source lang="javascript">
Code in here
</source>}}
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
INSERT INTO tblBusiness VALUES ('Michael's Hire and repair Shop','12 Tui St.', 'Napier', '(06) 123-4567','(021) 123-4567', 'info@mhirerepair.co.nz');
This causes a MySQL Error...
Solution |
---|
The problem here is that you have an extra quote after Michael effectively terminating the business description string. You can add a \ in front of the quote to "escape" it. Strings[1]
INSERT INTO tblBusiness VALUES ('Michael\'s Hire and repair Shop','12 Tui St.', 'Napier', '(06) 123-4567','(021) 123-4567', 'info@mhirerepair.co.nz'); |
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
References
- ↑ 8.1.1 Strings (2010) In MySQL 5.0 Reference Manual :: 8 Language Structure :: 8.1 Literal Values, Oracle. Retrieved September 10, 2010 from http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html
virtualMV | Superquick wiki guide | Please give me some feedback |
VirtualMV/MySQL/Interactive Help Desk. (2024). In WikiEducator/VirtualMV wiki. Retrieved November 23, 2024, from http:https://wikieducator.org/VirtualMV/MySQL/Interactive_Help_Desk (zotero)
|