How to get syntax error's specific description in mysql - mysql

My specific problem is solved before completing the question. But I still have a general question. It might be a duplicate but I am sorry I have been unable to find it on SO or elsewhere.
I have a table named reports. There is one row containing data. When I was trying to execute an update query I get an error:
error 1064: There is an error in your sql syntax near 'table='defect',Filter='' ,dtFilter='',query='Select allfields from defect' ,`da' at line 1
My question: is there a way to get my specific error? As it was just telling that there is error in SQL syntax but nothing about what type of error is.
Do I always have to google for such errors or there exists some technique to get their exact specific description locally?
Background (optional reading): after normal googling I got hint while posting question for better googling and get solved my specific problem as I came to know that it was problem of reserve words table and datetime. The problem solved when I put quotes around those words. This usually happens with me. But my general problem is still there...
It my be of no use now but I am sharing my schema here on sqlfiddle it might be useful

MySQL can't tell you that you are using a reserved word in wrong place (or your place is correct but used word is a reserve word, it cant differentiate) , it only only sees what you enter, it can't read the mind, so it can't know that you accidentally used (say) order as a field name, it'll just see a valid part of a query in the wrong place.e.g... a syntax error. It also won't report on ALL syntax errors in a query, because one syntax error renders the whole thing wrong. it can't skip over a word and keep parsing.

Nope - it just tells you the position, which hopefully is a decent clue.

Related

Error near the keyword 'Set' when trying to submite a while for data generate propose

I get this error but i don't have any idea how to solve this issue, i'm trying to run this script on Dbeaver it's a simply query but i try to look at all sources i could and dont get any answer, even on the dbeaver foruns.
The script is pretty basic, and the table has only 2 fields Id and Description it's just for pagination test...
I find the answer just by switching the "Id" for "Counter", maybe DBeaver treats the word "Id" in some different mode than others managers.

Rename an event in MySQL that has a space in the name

I'm still kind of new to MySQL as I've only used the most basic functions and I've only been getting more overwhelmed as I get into the more impressive sides of it. I decided to make a scheduler event and I screwed up. I put a space in the name. I've tried renaming it, but it doesn't seem to be able to read it.
ALTER EVENT 'update bills'
RENAME TO 'update_bills';
I wouldn't be surprised if this was due to naming it update. In any case I'm just hoping I don't have to delete the database and start over. I'm on a 1and1.com unlimited server, so the closest I can get to my database is phpMyAdmin and it just glitches out when I try to do something through the API and gives me a syntax error when I use the SQL command above.
If I have to start over, so be it, but if there's a way to rename this thing without destroying my day's worth of work, I'd be forever grateful.
Answer: I was using single quotes instead of the backquote (aka backtick, aka grave accent, aka this guy: ` ) character as e4c5 and reds pointed out in the comments and answer below. I didn't know there was a functional difference till now.
Do it like this way:
Alter EVENT `update bills` Rename To update_bills;
This char `` mysql need in any case to make your query construction DB Readable.
This is 100% working, Hope it helps

Why are there warnings rather than errors in MySQL?

I have been using MySQL to create a database and sometimes warnings come up rather than errors. An example is when I entered a page of full stops as a value. I do not really understand the point of these are why they appear instead of errors. Surely every incorrect value entered into a database should come up with an error, not just some. Please could somebody explain?
If you declared a column to be an integer but are attempting to insert a string, MySQL may perform implicit type conversion and emit an warning. See this question for a detailed example.
If you want to treat all warnings as errors, you should try strict mode.

Is there any way to retrieve more accurate MySQL error messages?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near [random snippet of query code]
I am very rarely able to deduce something of value from MySQL errors like that one, is there any way to get some more specific data?
I've seen people dismiss this question saying that it's impossible to get exact error data because of how MySQL's syntax works. Is that really so?
It's not only MySQL that gives syntax errors like that, MS SQL Server gives very similar messages.
The error message is very accurate in the sense that the code shown in the error message is the exact position where the parser determined that it could no longer go on with parsing the query.
However, the actual error in the query is often somewhat earlier in the query. If you for example misspelled "from" in a query as "fom", the parser will go on thinking that "fom" is an alias for the last field that came before that, and give you a syntax error when it finds a table name instead of the expected comma or "from" keyword. It will point to the table name as the position of the error instead of the misspelled keyword.
Sometimes it helps to break down your query into several lines instead of just one long one. This will still show you only the approximate position of your error, but it might help a bit.

Access query not working?

I remember using a query like this which worked for me before. But now its giving me a compile error.
I am trying to get only the first 3 characters of the second field.
select field1, left(field2, 3) from table1;
What am I doing wrong?
See this link:
http://www.techonthenet.com/access/questions/compile_error.php
It says you can get a compile error when using Left() if you have a broken reference. It also says how to fix it.
There is nothing wrong with your SQL statement. Brackets around field name, semicolon at end of statement, fewer than 3 characters in field2 --- those are all non-issues here.
There is something wrong with your database or your machine and/or its Access installation. Ordinarily I would suspect a references problem because your error is a classic symptom. However, in a comment, you indicated references are OK.
Create a new empty database and import table1 into it. Try your query in the new database. If it works there, you know the problem is limited to the original database. If the query does not work in the new database, copy the database to another machine which has Access installed and try it there. If it works on another machine, but not yours, ... I hope there is some way to repair your original machine without re-installing Office.
What happens in Access if you hit Ctrl-G on the keyboard and in the immediate window type "?Left("123Text", 3)" and hit ENTER? If you get the same compile error, then you have either a missing reference, or a compile error in your database.
To troubleshoot this, while in the VBE window, go to the DEBUG menu and select the first choice, COMPILE [project name]. You will likely receive notification of a compile error, and it should direct you to the problem that you need to fix.
Try putting the field name in square brackets
select field1, Left([field2], 3) from table1;
I don't see anything wrong with your SQL as long as your table names and column names are correct. Depending on your SQL editor or code, you may need to remove the semi colon from the statement.