PDA

View Full Version : adding/updating SQL?


reubenb
10-06-2005, 04:59 AM
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):

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.?

triad holdings
10-08-2005, 04:43 AM
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:

UPDATE personal SET personal_gender = 'male'


But if we wanted to set the user with 'personal_id' of 123 to 'male'
...we do..

UPDATE personal SET personal_gender = 'male' WHERE personal_id = '123'

reubenb
10-08-2005, 05:10 AM
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?