Jump to content

UPDATE multicolumns in TABLE


PriteshP23
Go to solution Solved by PriteshP23,

Recommended Posts

COUNT(*) 4

 

Hm.....it's very weird! What SQL editor are you using to achive that?

Anyways, it sounds like ( not sure) the SQL_SAFE_UPDATES is set up to ON.

So, before to send an update command to the sql server, run that:

SET SQL_SAFE_UPDATES=0;


Edited by jazzman1
Link to comment
Share on other sites

post your full table definition and the complete results of this query:

SELECT * (or at least "CustomerFirstName, CustomerLastName, ContactName and City")

FROM Customers

WHERE CustomerFirstName='Alfreds' AND CustomerLastName='Futterkiste'

 

 

ID     CustomerFirstName     CustomerLastName     ContactName     City     Company

 1                Alfreds                      Futterkiste                  NULL                    NULL        Dell

 3               Alfreds                       Futterkiste                  NULL                    NULL        Dell

 4               Alfreds                       Futterkiste                  NULL                    NULL        Dell

 5               Alfreds                       Futterkiste                  NULL                    NULL        Dell

 

Hm.....it's very weird! What SQL editor are you using to achive that?

 

I'm using database: MySQL client version: 5.0.45

 

I tried SET SQL_SAFE_UPDATES=0;   Can you tell me more about SAFE UPDATES ??

 

Still it's not working.. :confused:

Link to comment
Share on other sites

You didn't post the full definition of your table...the one that start with CREATE TABLE.... etc..etc

 

 

Here it is:

CREATE TABLE IF NOT EXISTS `Customers` (
  `ID` int(10) NOT NULL auto_increment,
  `CustomerFirstName` varchar(30) default NULL,
  `CustomerLastName` varchar(30) default NULL,
  `ContactName` varchar(30) default NULL,
  `City` varchar(30) default NULL,
  `Company` varchar(20) default NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Cutomers Data ' AUTO_INCREMENT=7 ;
Link to comment
Share on other sites

 

 

I tried SET SQL_SAFE_UPDATES=0;   Can you tell me more about SAFE UPDATES ??

 

It's a useful startup option for beginners in sql, which allows you to update(delete) rows only by specifying the key values that identify them, like in your example!

 

So, I don't see nothing wrong in your database structure. I am out.

Link to comment
Share on other sites

  • Solution

In database, I wrote:

UPDATE Customers

SET ContactName='Alfred Schmidt'  AND City='Hamburg'

WHERE CustomerFirstName='Alfreds' AND CustomerLastName='Futterkiste'

It must be:

UPDATE Customers

SET ContactName='Alfred Schmidt'  , City='Hamburg'

WHERE CustomerFirstName='Alfreds' AND CustomerLastName='Futterkiste'
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.