I need to replace "e; in a string. I tried to do this:
SET `title` = REPLACE( `title`, '"', '' )
but it gives me a parsing error.
This is 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
Server version: 5.5.57-cll - MySQL Community Server (GPL)
How do I do this?
Your query should work, but it seems like the error is from another query. Anyhow:
Try this:
UPDATE tbl_name
SET
field_name = REPLACE(field_name,
string_to_find,
string_to_replace)
WHERE
conditions;
Example:
UPDATE bbb_sefurls
SET
metatitle = REPLACE(metatitle,
'"e;',
'');
No need for a condition
This is simple approach but it replaces all the " in string.
UPDATE dummy_tab SET metatitle =REPLACE(metatitle,'/"','') WHERE metatitle LIKE '%"'
If I'm to read your error 100% as written... you have the word quote spelled wrong some where.
...for the right syntax to use near ''")'
notice in your error it shows no "e" There for your replace statement would also NOT catch this.
Or more closely looking at the image you posted... you are replacing
"e(semicolon)
with
''
But the error says it is finding the string
"e)
somewhere in your query... Which would seem to be invalid.
Search your code for
")
Related
I am trying to run an SQL Query to replace the spaces in my filenames with an underscore:
UPDATE oc_product_image set image=replace(image,' ', '_');
I found this sql query here: Remove space and replace with _ in phpMyAdmin
I am running it in the SQL tab in phpMyAdmin
When I simulate it I get 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 '' ''_') FROM oc_product_image WHERE' at line 1
What am I doing wrong?
Underscore is a special character in SQL. Try escaping it with a backslash and see if that helps.
Seems to be strange but very simple SQL query doesn't work for me.
UPDATE wp_postmeta SET `meta_value` = REPLACE(post_meta, `http://url/`, `http://new_url`)
Error message appears 'a new statement was found but no delimiter was found between it and the previous one (REPLACE) and when I'm trying to execute the 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. Please advise.
Your specific issue is the use of backticks rather than single quotes. However, I think a better way to express the logic is:
UPDATE wp_postmeta
SET meta_value = CONCAT('http://new_url', SUBSTRING(post_meta, 12) )
WHERE meta_value LIKE 'http://url/%' AND
meta_key = ??;
This uses the WHERE clause to filter out rows that should not be updated. It also ensures that the update is only to the occurrence of 'http://url/' at the beginning the string -- usually the logic that is intended.
I'm trying to search and replace in MYSQL but get an error. I'm quessing it's because of the "http://"
Anyone got any suggestions when trying replace this type of thing?
Code entered:
update movies_news set select_page = replace(select_page, ‘http://movie’, ‘http://www.movie’);
But it throws the following 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 '://movie’, ‘http://www.movie’)' at line 1
Posting so it can be accepted:
update movies_news set select_page = replace(select_page, ‘http://movie’, ‘http://www.movie’);
contains smart quotes, which are not interpreted as normal single quotes, thus the syntax error. It should instead be
update movies_news set select_page = replace(select_page, 'http://movie', 'http://www.movie');
In general, be really careful about copying code to and from 'smart' text editors (Microsoft Word, etc)
I am using mysql 5.5.27
At places where it looks like double quotes are two single quotes closer together, and they are actually null values in the excel sheetin the db.
I get the following error,
com.mysql.jdbc.exceptions.jdbc4.MySQLS… 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 'CASE,lname,fname,gender,dob,ssn,… at line 1
the actual query is
Insert into
work(CASE,lname,fname,gender,dob
"CASE" is a reserved word : See http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
You may escape it :
Insert into child(`CASE`,LASTNAME,FIRSTNAME,GENDER,DOB… American','1689 Crucible Street','','Pittsburgh','PA','15210','(4…
But I would personally prefer renaming the column.
CASE is a reserved word ... quote it ..
For mysql:
insert into tableName values()
Anyway you have SQL syntax errors:
Insert into child(CASE,LASTNAME,FIRSTNAME,GENDER,DOB… American','1689 Crucible Street','','Pittsburgh','PA','15210','(4…
Case is a reserwed word: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
In DOB… American' you miss a ' ('DOB… American')
The original query was:
UPDATE `test`.`documents` SET `title` = ‘测试中文’, `content` = ‘this is my test document number two,应该搜的到吧’ WHERE `documents`.`id` = 2;
Which resulted in:
#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 'my test document number two,应该æ
I changed the wrong '
UPDATE 'test'.'documents' SET 'title' = '测试中文', 'content' = 'this is my test document number two,应该搜的到吧' WHERE 'documents'.'id' = 2;
and got:
#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 ''test'.'documents' SET 'title' = '测试ä¸æ–‡', 'content' = 'this is my test do' at line 1
How do I set my my.ini?
I used XAMPP Lite, and MySQL version 5.1.37.
You're using ‘, instead of ', (that is, weird inverted commas)
For your new problem, you need to use `s (backticks) instead of ' (inverted commas) if you want to quote a table or column name.
Left and right single quotes (‘ and ’) should be replaced by normal apostrophe (').
Or is it called straight single quote?
Without knowing exactly where and how you're using that SQL statement, I can only guess that it could be an encoding problem. Try to change the encoding to UTF-8.
UPDATE test.documents
SET title = '测试中文',
content = 'this is my test document number two,应该搜的到吧'
WHERE documents.id = 2;
is also ok,and the same question is also my 3
all mysql table and field names should be escaped with backticks: `
all mysql strings should should be enclosed with single quote: '
try this:
UPDATE `test`.`documents` SET `title` = '测试中文', `content` = 'this is my test document number two,应该搜的到吧' WHERE `documents`.`id` = 2;
to address #3:
you need to alter the default charset for that table: "ALTER TABLEtest.documents. CONVERT TO CHARACTER SET utf8;" Be careful though, this may change the storage size requirements of the table, so if it's a large table, plan for the query to take a bit to execute.
to address #4:
you should add the following to the [mysqld] section of my.ini:
collation_server=utf8_unicode_ci
character_set_server=utf8