SQL syntax error in MySQL unsing a cast(Partition as Signed) - mysql

I have to support an application on a MySQL server. I can´t change the source code so I can´t change the used syntax.
My problem is that I always get an syntax error like this:
Microsoft OLE DB Provider for ODBC Drivers [-2147217900]
[MySQL][ODBC 5.1 Driver][mysqld-5.6.26]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 'Partition as Signed)' at
line 1
I looked into the log file and found the problem in this line:
Select *
from XYZ
where `Type`='something'
and Client='{3DBEA33A-9F0A-4e86-8354-F652713EA458}'
order by Cast(Partition as Signed);
I always get this error when the "Cast(Partition as Signed)" appears.
Is there any way to configure the server to accept this syntax?
I´m using MySQL (x64) 5.6.26 with InnoDB.

Partition is reserved word.
http://dev.mysql.com/doc/refman/5.6/en/keywords.html
you should use it with backticks
`Partition`

Related

Getting timestampdiff not working in Grails Gorm

I want to get time difference between two dates saved in MySql DB inside Grails criteria. For this purpose I have added below code in domain's mapping section.
formula: "(SELECT TIMESTAMPDIFF(SECOND, start_record, end_record))"
But SECOND is being treated as field and throwing sql syntax error.
There must be some trick to fix it, expecting it from SO community. Thanks
Error:
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 'this_.SECOND, this_.start_record, this_.end_record))) as y6_ from answer_meta_da' at line 1.
Grails Version: 3.3.9 | JVM Version: 1.8.0_121

Sql Syntax error with Doctrine, probably because of change of Mysql version

I've programmed a project in symfony and mysql 5.6. then I uploaded my project to a remote server on 1&1. the remote server has mysql 5.7 version. All doctrine queries run ok and without problem. But when a user searches something, a request will be sent to the server and a doctrine query will be executed. Here it returns the following error:
SQLSTATE[42000]: Syntax error or access violation: 1064 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 'integer)
BETWEEN 1940 AND 2002) AND u0_.id <> 2' at line 1
I think, it is probably because of different versions of mysql. Because on localhost it runs without problem
Can you please help me how to solve it? is there a way to regenerate all the migrations according the new mysql version? or may be there is another solution?
thanks
I was using CAST('number' as integer) in mysql 5.6. It did ok. However in mysql 5.7 and I do not know why, it does not run ok. So I changed it to CAST('number' as UNSIGNED) and it works ok

I can't read a database on mysql because of wrong syntax in the database name, but the database reads on other platforms like DBmaria

Hi please I am new to mysql and I'd love to know how to access a database with the name 'c-factory'. It seems mysql does not read it because of the '-' sign. I've been able to load it on dbmaria but I don't seem to be able to do it with mysql
SELECT * FROM c-factory
Error Code: 1064. 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 '-factory' at line 4 0.000 sec```

Why select json data not working in the mariadb?

My query like this :
select `information`->'$."full_name"' as `homeroom`
from `classes`
If the query run in my database local, it works. No error
But if the query run in my database server, it does not works. There exist error like this :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '>'$."full_name"' as `homeroom`
from `classes` LIMIT 0, 25' at line 1
If I run select version(),
My version database local : 8.0.15
My version database server : 10.0.38-MariaDB
Seems it does not work because my database server using mariadb
How can I solve this problem?
Update :
I using data type text to infomation field
JSON functions weren't added to MariaDB until version 10.2.3. If you can't upgrade you will have to process the data in your application. Note that even in versions that support JSON, they don't support the -> notation (reference) so you will have to rewrite the query as
JSON_EXTRACT(information, '$.full_name')

MySQL -Pentaho Error getting views from schema [null]

when trying to run Insert/Update or LookUp functions in Pentaho to get my SQL tables it shows me this error, anyone knows, how can I fix it?
Error getting views from schema [null]
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 'HAVING TABLE_TYPE IN ('VIEW',null,null,null,null) ORDER BY TABLE_TYPE, TABLE_SCH' at line 1
Downgrade your Mysql version compatible to Pentaho version. You should get that in your Pentaho manual.
I downgraded from mysql 8.0 to 5.6/5.5 and on 5.6 its got resolved.