Hi i have 2 databases in local host i want to copy UPC field from one to other if their product models are same?
I have tried this:
USE `medway_opencart` , `medway_eski_bakkal`
UPDATE `medway_opencart.product`
SET `medway_opencart.product.upc` = `medway_eski_bakkal.product.upc`
WHERE `medway_opencart.product.model` = `medway_eski_bakkal.product.model`
And i am getting 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 ' `medway_eski_bakkal` UPDATE `medway_opencart.product` SET `medway_opencart.' at line 1
Omit the first line, no need to use any database unless your using fully qualified name(db.table)
UPDATE `medway_opencart.product`
SET `medway_opencart.product.upc` = `medway_eski_bakkal.product.upc`
WHERE `medway_opencart.product.model` = `medway_eski_bakkal.product.model`
Unless you have priviledge to access both the databases..
Related
Hello I try do a Update like this
$sql = "UPDATE info SET YES/NO = '$_POST[value]' WHERE ID = '$_POST[id]'";
I am getting this error:
Error updating record: 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 '/NO = 'YES' WHERE ID = '5'
I think this can be error from use SLASH on my database, If it is the problem how can i solve it?, thanks and i cant find any on google working for it.
Usualy, anything different than alphanumeric and underscore is not recommended.
Indeed, it is not a good practice to name a colomn like you did.
I will recommend you to rename the colomn yes_no otherwise, you will get the same error again, again and again.
I am using MySQL 5.6 , one of my table field contains JSON data. I am getting syntax error when using below query -
SELECT * FROM products WHERE device_id = '1212'and product_id = '54'and option = '"{"229":"20"}"'
field option has value as {"229":"20"} I am getting 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 'option = '"{"229":"20"}"'
LIMIT 0, 25' at line 1
Please suggest any solution , thanks much!!!
option is a reserved keyword in MySQL. Use backticks to escape it or choose a different name
... `option` = ...
I am using following Insert statement to insert Blob row read from one database into another. (there is data when i echo the same insert statement).
UPDATE:
"INSERT INTO co_registration_picture_evidence_blb
(_URI, _CREATOR_URI_USER, _CREATION_DATE, _LAST_UPDATE_URI_USER, _LAST_UPDATE_DATE,
_TOP_LEVEL_AURI, VALUE) VALUES('".$imageRow['_URI']."','".$imageRow['_CREATOR_URI_USER']."','"
.$imageRow['_CREATION_DATE']."','".$imageRow['_LAST_UPDATE_URI_USER']."','".
$imageRow['_LAST_UPDATE_DATE']."','".$imageRow['_TOP_LEVEL_AURI']."'".
$imageRow['VALUE']."')"
I get following error 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 3
Update: Now i get this 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 '?PNG\r\n\Z\n\0\0\0\rIHDR\0\0\0?\0\0\0?\0\0\0????\0\0%iCCPICC Profile\0\0x??M' at line 3
Can anyone tell what's wrong with the syntax? my guess is that i should wrap VALUE column that is of type LongBlob (that holds an image) to some encoding function. (all data fields are already mysql_real_escape_string() filtered).
Any input would be really appreciated.
Regards.
You seem to be missing a , '
INSERT INTO co_registration_picture_evidence_blb
(_URI, _CREATOR_URI_USER, _CREATION_DATE, _LAST_UPDATE_URI_USER, _LAST_UPDATE_DATE,
_TOP_LEVEL_AURI, VALUE) VALUES('".$imageRow['_URI']."','".$imageRow['_CREATOR_URI_USER']."','"
.$imageRow['_CREATION_DATE']."','".$imageRow['_LAST_UPDATE_URI_USER']."','".
$imageRow['_LAST_UPDATE_DATE']."','".$imageRow['_TOP_LEVEL_AURI']."', '".
$imageRow['VALUE']."')
What did I change?
'".$imageRow['_TOP_LEVEL_AURI']."'".
'".$imageRow['_TOP_LEVEL_AURI']."', '".
I'm running this website.
I get a mysql error 1064 when i'm saving changes in my (wysiwyg) text editor
here is the first error
Database error: Invalid SQL: UPDATE page_master SET page_title =
'Help', page_content = '
MySQL 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 's bid online. We do charge tradesmen a small fee
for each quote they send. Howev' at line 1) Session halted.
and here is the second error
Database error: Invalid SQL: UPDATE page_master SET page_title =
'Terms and Conditions and use', page_content = '
MySQL 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 's web site is available only to individuals who
can form legally binding contrac' at line 1) Session halted.
Here is my sql table.
http://pastebin.com/F15P91TM
As you confirmed my comment above you have to escape the string you want to store in your database.
There just use the real_escape_string function, see manual: http://www.php.net/manual/en/mysqli.real-escape-string.php
If you are still using the deprecated mysql_*-functions, you have to use: http://php.net/manual/de/function.mysql-escape-string.php. But again, the use of mysql_* is deprecated and should not be used anymore!
I am trying to write a script that archives a user by setting the value of the archive column to the value of 1 . I have written the following script to do this, but I am not sure if I am using the syntax correctly as I am am getting the following error.
<?php
mysql_query("SELECT FROM archive hqfjt_chronoforms_data_addupdatelead
WHERE cf_uid = '{cf_uid}'
SET archive='1';"
) or die(mysql_error());
?>
The error I am getting is:
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 cf_uid = 'c68235f3fb5c3f7fff6247b04c450dd7' SET archive='1'' at line 1
There's no SET in a SELECT statement, and you're missing the FROM part.
You need an UPDATE command, perhaps like:
UPDATE archive SET archive='1' WHERE cf_uid = '$cf_uid'
UPDATE archive, not SELECT archive. Also, you're inviting a visit from little Bobby Tables.