Hi iam trying to change the path in some links in my WordPress database.
In my table wp_commeentmeta, I am using the syntax:
UPDATE table SET meta_value = REPLACE(meta_value, 'http://articles.mydomain.com', 'http://localhost/articles')
BUT I get 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 'table SET meta_value = REPLACE(meta_value,
'http://articles.mydomain.com', 'http' at line 1
Any help on this please?
Please note : I am using phpMyAdmin for this.
Change the table to be the name of your table
UPDATE wp_commeentmeta
SET meta_value = REPLACE(
meta_value,
'http://articles.mydomain.com',
'http://localhost/articles'
);
(Just fyi, the linebreaks aren't important, just makes the query more readable)
Related
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
")
Sorry if the question is badly worded, essentially i'm trying to do something like this
mysql --user user --p password database -e " SELECT * FROM
`wp_postmeta` WHERE `meta_key` LIKE '_sku' AND `meta_value` = '';" | awk ' { print $2 } ' > post_id_data.txt
However when I run this style of code i'm getting errors and i'm not sure why, reason being as the mysql statement is straight from phpmyadmin and works when i connect to the mariadb database.
I have tried to remove some of the back ticks so that they are more like this
'' instead of whats being shown but still no luck instead I get this error
ERROR 1064 (42000) at line 1: 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 ''wp_postmeta' WHERE 'meta_key' LIKE '_sku' AND
'meta_value' = ''' at line 1
Another example of code that I have tried can be seen below.
#!/bin/bash
MYSQLUSER="user"
MYSQLPASS="password"
database="wordpress"
#mysql options to be parsed
MYSQLOPTS="--user=${MYSQLUSER} --password=${MYSQLPASS} ${database}"
mysql ${MYSQLOPTS} << EOFMYSQL
SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE '_sku' AND `meta_value` = '';
EOFMYSQL
I Have also tried
root#3e0a62b6b42c:/# mysql --user=user--password=passowrd wordpress -e
"SELECT * FROM 'wp_postmeta' WHERE 'meta_key' LIKE '_sku' AND
'meta_value' = '';"
ERROR 1064 (42000) at line 1: 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 ''wp_postmeta' WHERE 'meta_key' LIKE '_sku' AND 'meta_value' = ''' at line 1
Please note that i'm new to Mysql so any references to good learning material where I can do thing such as this is deeply appreciated
Remove the semicolon and quotes around column/table names.
The mysql tool explodes when you terminate your query with a semicolon.
Use backticks to quote entity names if you need to, not quotes.
Try this:
"SELECT * FROM wp_postmeta WHERE meta_key LIKE '_sku' AND meta_value = ''"
I want Update an SQL tablein phpMyAdmin, to change a values of a column.
My request is:
Update article set Id_LRU where ID_Article='DIEPRESTATION'
It return an 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 'where ID_Article='DIEPRESTATION'' at line 1
I changed it by using like because the type of the field is a Varchar:
Update article set Id_LRU where ID_Article like 'DIEPRESTATION'
Also it got the same error.
How can I correct it please .
You have syntax error.
Update article set Id_LRU ='YOURVALUE' where ID_Article like 'DIEPRESTATION'
Try above query.
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.
asp --> odbc --> mysql, multi query problem.
dbCon.execute("update wp_posts set post_abc = '1234' where ID=1602';");: no problem
dbCon.execute("set #aa=1602;update wp_posts set post_abc = '1234' where ID=#aa;");: error
err message:
[MySQL][ODBC 5.2(w) Driver][mysqld-5.1.45p1-log]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 'update wp_posts........
How can I fix this? SOS!!!
Dislikes answers:
dbCon.execute("set #aa=1602;");
dbCon.execute("update wp_posts set post_abc = '1234' where ID=#aa;");
Add MULTI_STATEMENTS=1 in the connection-string, or enable multiple queries in the DSN entry by going to
Details -> Connection -> Allow multiple statements