unexpected execution of update query in MySql-Collection of common programming errors
i have a table in MySql as:
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;
my first query is:
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')
this query is executing
the sub_product_id generated on execution of above insert statement is 38
now my application needs to fire this update query after the previous insert query
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
but the result is unexpected:
all the fields value is not setting accordingly as stated in the above update query
i am getting the result something like this: the image2_path fields value becomes 0 and all the rest fields value remains the same un-updated
please help me find the mistake