Re: MySQL update statement problem
| From: | Chris | Date: | Sat, 04 Mar 2006 17:47:04 +0000 |
| Subject: | Re: MySQL update statement problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41379@lists.php.net to get a copy of this message | ||
You need to separate the SET arguments with commas, not ANDs...
It's really doing something like this:
UPDATE shop_customer SET eu_vat_number = ("SK1234567890" AND vat_amount = 0
AND total_amount = 8.4925) WHERE customer_id = 7 AND hash="dcd5e751"
("SK1234567890" AND vat_amount = 0 AND total_amount = 8.4925) evaluates to false (0) , so that's what gets set.
Kevin Davies - Bonhurst Consulting wrote:
Hi, Apologies if this isn't the right place to ask - but I'm banging my head against the wall with this one! I'm trying to update a record in the table (creation script below) using the following SQL statement: UPDATE shop_customer SET eu_vat_number = "SK1234567890" AND vat_amount = 0 AND total_amount = 8.4925 WHERE customer_id = 7 AND hash="dcd5e751" Before running the query the value for eu_vat_number is 'null', vat_amount is 0.085 and total_amount = 8.5775. After I run the query (mysql_affected_rows = 1) the values for vat_amount and total_amount remain the same, but vat_number is changed to 0. I've been looking at this most of the afternoon, and it's probably something really simple but I just can't see it... Any ideas? Thanks in advance for your help... Cheers, Kev -- Server version: 3.23.58 -- PHP Version: 4.3.10 CREATE TABLEshop_customer(customer_idint(11) NOT NULL auto_increment,hashvarchar(8) NOT NULL default '',first_namevarchar(255) NOT NULL default '',last_namevarchar(255) NOT NULL default '',email_addressvarchar(255) NOT NULL default '',member_idint(11) default NULL,address1varchar(255) default NULL,address2varchar(255) default NULL,townvarchar(255) default NULL,countyvarchar(255) default NULL,postcodevarchar(255) default NULL,countryint(11) NOT NULL default '0',eu_vat_numbervarchar(15) default NULL,total_itemsint(11) default '0',net_amountfloat default '0',vat_amountfloat default '0',shipping_amountfloat default '0',total_amountfloat default '0',addeddatetime NOT NULL default '0000-00-00 00:00:00',payment_receiveddatetime default NULL, PRIMARY KEY (customer_id) ) TYPE=MyISAM AUTO_INCREMENT=8 ;