我在MySql中有一个表格:
CREATE TABLE products (
sub_product_id int(10) NOT NULL AUTO_INCREMENT,
sub_product_name varchar(15) NOT NULL,
price int(10) NOT NULL,
available_qty int(10) NOT NULL,
image1_path varchar(50) NOT NULL,
image2_path varchar(50) NOT NULL DEFAULT '~//uploaded_img//not_uploaded.jpg',
image3_path varchar(50) NOT NULL DEFAULT '~//uploaded_img//not_uploaded.jpg',
image4_path varchar(50) NOT NULL DEFAULT '~//uploaded_img//not_uploaded.jpg',
image5_path varchar(50) NOT NULL DEFAULT '~//uploaded_img//not_uploaded.jpg',
shipping_details varchar(200) NOT NULL DEFAULT 'shipping details not specified yet',
price_details varchar(200) NOT NULL DEFAULT 'price details not specified yet',
products_brand varchar(50) NOT NULL DEFAULT 'product''s brand not specified yet',
category_name varchar(15) NOT NULL,
sub_category_name varchar(30) NOT NULL,
description varchar(500) NOT NULL,
product_name varchar(50) NOT NULL DEFAULT 'product''s name not specified yet',
title varchar(100) NOT NULL,
user_id int(10) NOT NULL,
date_of_creation date NOT NULL,
PRIMARY KEY (sub_product_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
我的第一个问题是:
insert into products (sub_product_name,price,available_qty,image1_path,products_brand,category_name,sub_category_name,description,product_name,title,user_id,date_of_creation) values('','14','45','~//uploaded_img//AD_IMG63.jpg','','Electronics','Camera Digicams','Product Description here','','Product Title Here','43','2011/04/03')
此查询正在执行
执行上述insert语句时生成的sub_product_id为38
现在我的应用程序需要在上一次插入查询后触发此更新查询
update products set image2_path='~//uploaded_img//AD_IMG64.jpg' and image3_path='~//uploaded_img//AD_IMG65.jpg' and image4_path='~//uploaded_img//AD_IMG66.jpg' and image5_path='~//uploaded_img//AD_IMG67.jpg' and shipping_details='Shipping Details here' and price_details='Price Details here' and description='Product Description here' where sub_product_id=38
但结果出乎意料:
所有字段值均未按照上述更新查询中的说明进行相应设置
我得到的结果是这样的: image2_path字段值变为0 并且所有其余字段值保持不变未更新
请帮我找错误
答案 0 :(得分:2)
而不是
update products set image2_path='..' and image3_path='..'
试
update products set image2_path='..', image3_path='..'