Jump to content

UPDATE multicolumns in TABLE


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;


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:

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 ;

 

 

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.

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'

LOL, the query you posted at the start of this thread is the correct syntax and we only see and can only help you based on the information you provided in your posts.

 

in the future, copy paste the actual query/code you need help with to avoid wasting everyone's time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.