Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching and Destroying "NULL"s 1

Status
Not open for further replies.

Tama

MIS
Jun 6, 2001
121
NZ
I run a MySQL based web forum, and am in the process of migrating the data across.

When I saved the original data as a MySQL query a few of the fields had "NULL" in them - fair enough I thought.

Now I've migrated the data back into my new system fields with "NULL" in them are registering as the text string "NULL" rather than blank/empty/null - so for example if a user did not put any interests down in the old system the new system is displaying "Interests:NULL" - ugly.

Is there any danger of me doing a search and replace on the relevant tables so that "NULL" entries are replaced with a blank entry? Can someone give me the proper syntax so I don't screw it up?

Thanks in advance
Tama
 
i think this should work

UPDATE TABLE <tablename> SET Interests = NULL WHERE Interests = 'NULL'
 
That worked well - cheers Piti

Now, on a similiar problem - I have a table with the field &quot;score&quot; where I want to multiply every single value of score by a certain amount (say 1.1) is it possible to just write:

UPDATE TABLE <tablename> SET score = (score * 1.1)

Thanks again.
Tama
 
that should work

btw - why don't you create a test table and try by yourself ;-)
 
Good idea - I really should be more adventurous :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top