Forum Moderators: open

Message Too Old, No Replies

Question on doing a MySQL update

         

smithaa02

2:19 pm on Jul 31, 2007 (gmt 0)

10+ Year Member



Say I have a table like this:

Table Name: People

Fields: id, name, official_name, etc

It's populated like:

1,frank,null
2,jo,null
3,sam,null
etc...

How would I update all official_name fields with the name fields?

So the table would become:
1,frank,frank
2,jo,jo
3,sam,sam

Is there an update that can do this in MySQL?

Duskrider

2:32 pm on Jul 31, 2007 (gmt 0)

10+ Year Member



How about:

UPDATE People SET official_name = name WHERE official_name = 'NULL'

Should do it.