Welcome to WebmasterWorld Guest from 54.196.107.247

Forum Moderators: open

Message Too Old, No Replies

INSERT vs. UPDATE for column data

Can I use UPDATE if the column value is NULL?

     
5:48 pm on Jun 13, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 26, 2006
posts: 41
votes: 0


Hi,

I'm wondering if it's possible to use UPDATE on a row where it's unknown whether the column being updated already has a value or not.

If the column's value is set to NULL, will UPDATE work? Or do I really need to test for NULL and write either an UPDATE or an INSERT query? I'd really like to streamline my code by not having to do the test, but I don't know how far UPDATE will go.

By the way, I looked at REPLACE INTO, but I'm not worried about an entire row of data, just a single column in an existing row.

Thanks,
Glenn

8:26 am on June 14, 2008 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10847
votes: 61


INSERT inserts a new ROW.
UPDATE modifies an existing row's VALUE(s).
7:55 pm on June 14, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 26, 2006
posts: 41
votes: 0


Thanks. Of course you're right. That clears things up for me. UPDATE it is!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members