Correct Syntax for SQL UPDATE statement - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

kenkofi
Posts: 3
Joined: Wed Jul 16, 2008 8:44 pm

Correct Syntax for SQL UPDATE statement

If have succesfully created a connection which works perfectly when using the SQL INSERT statement. However, when I try to UPDATE an existing table. using standard SQL UPDATE syntax it doesn't work. I have spent over an hour trying every possible syntax permutation, but nothing works.

Following have been tried:
UPDATE 'Useage'
SET AllowedUse = '6'
WHERE AllowedUse = '5';

UPDATE 'Useage'
SET 'AllowedUse' = '6'
WHERE 'AllowedUse' = '5';

UPDATE 'Useage'
SET 'AllowedUse' = '6',
WHERE 'AllowedUse' = '5';

UPDATE 'Useage'
SET ('AllowedUse' = '6'),
WHERE ('AllowedUse' = '5');

UPDATE Useage
SET ('AllowedUse' = '6'),
WHERE ('AllowedUse' = '5');


UPDATE 'Useage' SET AllowedUse = '6' WHERE AllowedUse = '5';



There has to be simple way to do this. Please any ideas anyone.
dms
Posts: 164
Joined: Tue Aug 28, 2007 7:11 am
Location: UK

Re: Correct Syntax for SQL UPDATE statement

Ok

Assuming that your table is 'Useage' then your first line is obviously correct

Update Useage

Your next line will obviously refer to the column that you want to update so

Set Alloweduse = 6 should also be correct

However how do you know to which row to refer?

Your third line need to specify the row so you ought really be refereing to the row id so

Where [row id ] = {add row id here]

HTH
Dom
kenkofi
Posts: 3
Joined: Wed Jul 16, 2008 8:44 pm

Re: Correct Syntax for SQL UPDATE statement

Hi Dom

Thank you for your response. The table contains a single row, so knowing which row to update is not an issue. The only row to update already contains the value 5 which needs to be replaced with 6.

I managed to get this to work using the following syntax. I am trying to work out the syntax is for update multiple fields, but again trial and error seems to be the only way because standard SQL syntax doesn't seem to work.

UPDATE Useage SET Allowed = '6' WHERE AllowedUse = 5;

Thanks for your input.

Regards

Kenkofi

Return to “Common Problems”