Jump to content


Photo

Multiple update syntax


  • Please log in to reply
5 replies to this topic

#1 leedude

leedude
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 07 August 2006 - 04:44 PM

is there a way i can selectively update columns like i can with the insert command:

update table1 set (page,title,dsc) = (1,"Page 1","This is Page 1") where id = 4;

(this is excluding the id column from the update).
This produces an error, is there a way i can do this like i can insert data:?

insert into table1 (page,title,dsc) values (1,"Page 1","This is Page 1")

plz help.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 07 August 2006 - 04:48 PM

$query = "UPDATE table1 SET (page,title,doc) VALUES('1','Page 1','This is Page 1') where id = '4')";

Legend has it that reading the manual never killed anyone.
My site

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 07 August 2006 - 05:05 PM

Really?!? I didn't know that syntax was even possible.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 leedude

leedude
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 07 August 2006 - 05:13 PM

thankyou thankyou thankyou!!!!!!!!!!!!!!!!!!

;D ;D ;D ;D ;D ;D ;D ;D

#5 leedude

leedude
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 07 August 2006 - 05:18 PM

or actually not...
It still brings an error.  :-\

And i cant help noticing that there appears to be an extra close-bracket at the end.

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 07 August 2006 - 06:04 PM

Well, you can always try the old-fashioned way:

$query = "UPDATE table1 SET page = '1', title = 'Page 1' , doc = 'This is Page 1' where id = '4'";

Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users