Jump to content


Photo

update


  • Please log in to reply
3 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 12 April 2006 - 09:30 AM

Hi,

I have:-

INSERT INTO table2 (letter) SELECT letter FROM table1 ORDER BY RAND()

which takes 26 records from table1 and inserts them into the letter field of table 2

but how can i

update exsisting records in table2 and not insert?



#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 12 April 2006 - 10:02 AM

i *think* this will work

UPDATE table2 SET `fieldname` = (SELECT letter FROM table1 ORDER BY RAND())


but i'm not 100 % on it

www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 12 April 2006 - 10:13 AM

Have a look at SELECT INTO [a href=\"http://www.w3schools.com/sql/sql_select_into.asp\" target=\"_blank\"]here[/a]

#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 12 April 2006 - 10:44 AM

i dont think select into is really what i want, but i might be wrong, as far as i can see that just creates a new table, but i dont want a new table.

the () in the query hasnt worked..

any other ideas please?





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users