Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts

    How Do I set empty fields as NULL?

    I've got a whole bunch of empty values in the MFG field of my stock table, and I need to make them NULL.

    I don't really even know where to start.
    Any pointers?

    My first thought:
    Code:
    UPDATE Stockline
    SET mfg=NULL
    WHERE mfg :confused:
    ~ Mo

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    try a "show create table Stockline" and post the result.

    best regards

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well if mfg is a string column:

    Code:
    UPDATE SET mfg=null WHERE mfg = ''
    Also remember to backup the table before you do wide sweeping changes like this.

    If there are ones with spaces or tabs you'd like to replace with null, that can be done with a trim function.
    OracleGuy

  • #4
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Thanks oracleguy, that now seems painfully obvious.

    And thanks for the reminder to backup, as well as the suggestion of trim for tabs and spaces.

    ~ Mo


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •