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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts

    adding/updating SQL?

    hi,
    if i had a form, that some fields weren't required, at the database the INSERT INTO field works nicely, even if some fields are =''
    but when it comes to editing(UPDATE) where some fields aren't required, it gives an error [this would be the output):
    Code:
    UPDATE personal SET personal_gender = '', personal_height = 235 WHERE personal_id = Request.QueryString("expand")
    how can i fix this?
    btw, the error is just 'syntax error'
    i am using an access database with asp.?

  • #2
    New to the CF scene
    Join Date
    Oct 2005
    Location
    North Carolina
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not sure if this will help with the asp thing there but let me give this a shot.

    The main things you need to remember are the keywords.

    UPDATE, SET, WHERE -- for an update

    You don't need a WHERE, but it's better, so you don't update the whole table.

    So for example.. We have a table called... "personal" and in that table we have the columns, "id, personal_id, personal_gender, personal_height"

    We could update the table and change everyone's password to 'male', by doing:
    Code:
    UPDATE personal SET personal_gender = 'male'
    But if we wanted to set the user with 'personal_id' of 123 to 'male'
    ...we do..
    Code:
    UPDATE personal SET personal_gender = 'male' WHERE personal_id = '123'

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    ok
    thanks
    but..
    the SQL i wrote is so that it updates all the available fields in the database with the fields from the form..
    but thsoe fields arent compulsory
    so the SQL will do ='' if theres nothingin the field
    cauaising the SQL do die.

    how do i fx this?


  •  

    Posting Permissions

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