Syntax error or access violation on MySQL geometry data type - mysql

I am working with datatype geometry on MySQL. I try to query from the page. I got the error.
How to fix? Could you please help?
Error here:
"An exception occurred while executing '
SELECT t.`road_id`, t.`road_ref_num`, t.`chainage`, t.`road_name`,
ST_AsGeoJSON(ST_Transform(t.`road_wkt`, ?::int)) as geom
FROM gis_ruralroads_t1 t
WHERE (t.road_ref_num LIKE ?)
AND (ST_Transform(ST_SetSRID(ST_MakeBox2D(ST_Point(?, ?),
ST_Point(?, ?)), ?), ST_Srid(t.`road_wkt`)) && t.`road_wkt`
)
with params [32648,
"%0806T1001%", 5579.905, 1088581.723, 1029359.857, 1650396.77,
32648]
SQLSTATE[42000]: Syntax error or access violation: 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 '::int)) as geom FROM gis_ruralroads_t1 t WHERE (t.road_ref_num LIKE '%0806T1001%' at line 1"
Best,
Loy

It is pointing right at ::int. MySQL does not have any syntax like that. Simply remove those 5 characters.
In general, you can trust that an integer will be correctly substituted, even if quotes are added:
ST_Transform(t.`road_wkt`, ?)
turns into this after substitution:
ST_Transform(t.`road_wkt`, '32648')
The apostrophes won't hurt.

Related

Syntax Error or access violation - SQL query & Laravel

In my query, i am trying to compare today's date only (without time) to my field created_at but i get the error below
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 '2018-08-29 DATE(created_at)' at line 1
Controller
$item_shipped = Item::where('id',Auth::user()->id)->whereRaw('DATE(created_at)' , '=', Carbon::now()->toDateString())->get();
return $item_shipped;
How do i solve this problem ?
whereRaw doesn't accept the operator parameter. You have to write the whole condition and it takes the second parameter which is an array of bindings.
You need this:
->whereRaw('DATE(created_at) = ?', [Carbon::now()->toDateString()])->get();

web application got a error mysql query

select b1.blog_id, blog_name, blog_desc, b1.blog_date, blog_author, blog_img, ifnull(count(blog_cmt),0) AS blog_cmt
from blog b1, user_blog b2"
I got a error in this:
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 '"' at line 1
Error #1064 means that MySQL can't understand your command. To fix it:
Read the error message. It tells you exactly where in your command
MySQL got confused.
Check the manual. By comparing against what MySQL
expected at that point, the problem is often obvious.
Check for reserved words. If the error occurred on an object identifier, check
that it isn't a reserved word (and, if it is, ensure that it's
properly quoted).
You need to remove the quotes at the end and run your query. Looks like there is a typo, you intended a ; instead.
select b1.blog_id, blog_name, blog_desc, b1.blog_date, blog_author, blog_img, ifnull(count(blog_cmt),0) AS blog_cmt
from blog b1, user_blog b2;

Error #1064 SQL when try to convert to VARCHAR with thousand commas

I got this error:
"#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 'varchar,convert(Money, donate_amt),1),'.00','')' at line 1"
when try to convert all the Number of column: donate_amt, table" "corp_donate". Can help me how to fix it. Below is the code I tried:
select replace(convert(varchar,convert(Money, `donate_amt`),1),'.00','')
select replace(convert(varchar,cast(donate_amt as money),1), '.00','')
try this....

sql syntax error storing html table as text in mysql

Query to insert text in database is:
INSERT INTO uri VALUES('')
I'm getting follwing Syntax error:
MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
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 'liq" style="font-size:110%;font-family:'Alvi Nastaleeq', 'Nafees Nastaleeq', 'Na' at line 1
change this
title=\"Nasta'liq\"
^-----you have single quote alone here .get rid of it
to
title=\"Nasta liq\"
or
title=\"Nastaliq\"

load SQL and ignore duplicates

I want to import an SQL file using PHPMyAdmin where I know duplicates exist. I am using the syntax:
LOAD DATA INFILE 'C:\Documents and Settings\...\db_settings_extends.sql' ignore;
I receive the error:
#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 '' at line 1
How do I correct this?
From the error message, it looks like duplicates are not the problem. It seems to not like your string value or something next to it.