Grails : MySQL server version for the right syntax to use near ')) - mysql

I am using Grails 2.3.4 and having trouble with named queries.
For example:
def c = Party.createCriteria()
completedSearchList = c.list(max: params.max, offset: params.offset){
if(params.searchText) {
or {
ilike("FirstName", "%${params.searchText}%")
ilike("pDate", "%${params.searchText}%")
"in"("user",users)
}
and {
eq("status","COMP")
}
and {
eq("projectID",session.projectID)
}
}
}
Goal is to bring the search value written in the search field through param value and use Grails criteria to search.
But I am getting the error msg like:
Stacktrace follows:Message: 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 ')) and (this_.status='COMP') and (this_.projectid='bacrt') limit 10' at line 1

Related

MySQL Syntax error in the update statement, NodeJS(MySQL2) module

I am using Node.JS along with the mysql2 module. It's basically like when I try to update a column with a JSON stingified data, I get the following error:
{ Error: 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 '"1050":1}WHERE
`user` = ?' at line 1
The stingified JSON data:
{"1050":1}
The query:
var sql = 'UPDATE `users` SET `furniture` = ' + 'concat(furniture,' + JSON.stringify(self.furniture) + ')' + 'WHERE `user` = ?';
self.furniture is related to something else, but I can assure you that self.furniture is returning that JSON data thus I get the mysql syntax error.
sqlMessage: '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 \'"1050":
Issue is resolved using backticks along with single quotes.
var sql = 'UPDATE `users` SET `furniture` = ' + `concat(furniture, '${lol}')` + 'WHERE `user` = ?';
var lol = JSON.stringify(self.furniture)
Your query line says in part
...ingify(self.furniture) + ')' + 'WHERE `us...
It should have an extra space after the close parenthesis.
...ingify(self.furniture) + ') ' + 'WHERE `us...
Here's the thing about MySQL syntax errors: the message shows the erroneous query starting with the first character MySQL does not understand. A good way to troubleshoot this kind of thing is to use console.log() to output the entire query string, then look at it carefully. You will usually find something obvious wrong.

How to append string to column

I want to append a string as a prefix to the values of a column. When I try this one:
UPDATE ortsbezug SET Zusatz = CONCAT("Nordseite",Zusatz) WHERE FSOrtID = 2425;
I always get an error:
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 ') FROM ortsbezug WHERE FSOrtID = 2425 AND (Zusatz <> CONCAT("Nordseite" OR Zus' at line 1
Anyone has an idea where exactly the error could be?
screenshot of query and error

Error in SQL syntax MySQLSyntaxErrorException in Grails

I do request to MySQL database, which searches data in table by criteria:
def tableAcounting(){
def user = Person.findByUsername(springSecurityService.currentUser.username)
def cafee = user.cafee
def tablesQuery = TablePlacesInfo.createCriteria()
def tables = tablesQuery.list { //AN ERROR SHOW ON THIS STRING
'in'("hall", HallsZones.findAllByCafee(cafee))
}
def halls = cafee.halls
But I get such error:
Class:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
Message: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 ')' at line 1
This usually happends if you do an in search using an empty set. This means, that you need to check the size of HallsZones.findAllByCafee(cafee) because this set is probably empty.

How to write scope where one attribute is less than other?

I tried this one
scope :opened, lambda {
where("entries_count <= limit")
}
But I get an error:
Mysql2::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 'limit)' at line 1: SELECT shifts.* FROM shifts WHERE
(entries_count <= limit)
Are both entries_count and limit active record attributes mapped to columns?
scope :opened, -> { where(:entries_count <= :limit }
You can get this with:
scope :opened, lambda { |limit| where("entries_count <= ?", limit) }
or this way that is in a more updated syntax for lambda:
scope :opened, -> limit { where("entries_count <= ?", limit) }

SQL syntax Limit 1 error

WordPress database 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 'LIMIT 1' at line 4
for query
SELECT wp_wpsp_templates_fonts.name
FROM wp_wpsp_templates_fonts
WHERE wp_wpsp_templates_fonts.fontID =
LIMIT 1
made by
require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/twentyten/wpsp-sales-page.php'), require_once('/plugins/wpsp/wpsp-frontend.php'), TemplatesModel->GetFontByID
Below is the code.
function GetFontByID($fontID) {
global $wpdb;
$results = $wpdb->get_results(" SELECT ".$wpdb->prefix."wpsp_templates_fonts.name
FROM ".$wpdb->prefix."wpsp_templates_fonts
WHERE ".$wpdb->prefix."wpsp_templates_fonts.fontID = ".mysql_real_escape_string($fontID)."
LIMIT 1");
return $results[0]->name;
}
Any ideas on how to fix this issue?
GetFontByID() needs a parameter passed to it. Currently, the param appears blank.