{"id":7277,"date":"2014-06-03T23:30:28","date_gmt":"2014-06-03T23:30:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/unexpected-execution-of-update-query-in-mysql-collection-of-common-programming-errors\/"},"modified":"2014-06-03T23:30:28","modified_gmt":"2014-06-03T23:30:28","slug":"unexpected-execution-of-update-query-in-mysql-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/unexpected-execution-of-update-query-in-mysql-collection-of-common-programming-errors\/","title":{"rendered":"unexpected execution of update query in MySql-Collection of common programming errors"},"content":{"rendered":"<p>i have a table in MySql as:<\/p>\n<pre><code>        CREATE TABLE products (\n          sub_product_id int(10) NOT NULL AUTO_INCREMENT,\n          sub_product_name varchar(15) NOT NULL,\n          price int(10) NOT NULL,\n          available_qty int(10) NOT NULL,\n          image1_path varchar(50) NOT NULL,\n          image2_path varchar(50) NOT NULL DEFAULT '~\/\/uploaded_img\/\/not_uploaded.jpg',\n          image3_path varchar(50) NOT NULL DEFAULT '~\/\/uploaded_img\/\/not_uploaded.jpg',\n          image4_path varchar(50) NOT NULL DEFAULT '~\/\/uploaded_img\/\/not_uploaded.jpg',\n          image5_path varchar(50) NOT NULL DEFAULT '~\/\/uploaded_img\/\/not_uploaded.jpg',\n          shipping_details varchar(200) NOT NULL DEFAULT 'shipping details not specified yet',\n          price_details varchar(200) NOT NULL DEFAULT 'price details not specified yet',\n          products_brand varchar(50) NOT NULL DEFAULT 'product''s brand not specified yet',\n          category_name varchar(15) NOT NULL,\n          sub_category_name varchar(30) NOT NULL,\n          description varchar(500) NOT NULL,\n          product_name varchar(50) NOT NULL DEFAULT 'product''s name not specified yet',\n          title varchar(100) NOT NULL,\n          user_id int(10) NOT NULL,\n          date_of_creation date NOT NULL,\n          PRIMARY KEY (sub_product_id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;\n<\/code><\/pre>\n<p>my first query is:<\/p>\n<pre><code>    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')\n<\/code><\/pre>\n<p>this query is executing<\/p>\n<p>the sub_product_id generated on execution of above insert statement is 38<\/p>\n<p>now my application needs to fire this update query after the previous insert query<\/p>\n<pre><code>    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\n<\/code><\/pre>\n<p>but the result is unexpected:<\/p>\n<p>all the fields value is not setting accordingly as stated in the above update query<\/p>\n<p>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<\/p>\n<p>please help me find the mistake<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;~\/\/uploaded_img\/\/not_uploaded.jpg&#8217;, image3_path varchar(50) NOT NULL DEFAULT &#8216;~\/\/uploaded_img\/\/not_uploaded.jpg&#8217;, image4_path varchar(50) NOT NULL DEFAULT &#8216;~\/\/uploaded_img\/\/not_uploaded.jpg&#8217;, image5_path varchar(50) NOT NULL DEFAULT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7277","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7277"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7277\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}