corsasport.co.uk
 

Corsa Sport » Message Board » General Chat » access update query help


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author access update query help
chris_lee100
Member

Registered: 14th Jul 02
User status: Offline
30th Jan 05 at 20:38   View User's Profile U2U Member Reply With Quote

I have a number of records with a field in which has a number I wish to add eg I want to make the record 100 into 1100. What is the sql in the "update to" field for this to happen?


Cheers, Chris
Joff
Member

Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
30th Jan 05 at 20:39   View User's Profile U2U Member Reply With Quote

code:
UPDATE table_name SET field_name = new_value WHERE field_name = old_value
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
30th Jan 05 at 20:41   View Garage View User's Profile U2U Member Reply With Quote

Don't think you can do this with a single UPDATE.

Also consider whether this is a bit of maths in which you're adding 1000, or a string operation in which you're placing a 1 at the front of the existing number. Its not the same operation.
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
30th Jan 05 at 20:43   View Garage View User's Profile U2U Member Reply With Quote

You can't say this though, unless Access suports sub-selects?
code:

UPDATE table_name SET field_name = "1" & old_value WHERE field_name = old_value


[Edited on 30-01-2005 by Ian]
Joff
Member

Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
30th Jan 05 at 20:46   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Ian
Don't think you can do this with a single UPDATE.

Also consider whether this is a bit of maths in which you're adding 1000, or a string operation in which you're placing a 1 at the front of the existing number. Its not the same operation.


From the sounds of it, he's just updating the value, not performing a sum.

Multiple updates will work with that code above in Access, SQL 2k and mySQL. Just tried.
Joff
Member

Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
30th Jan 05 at 20:49   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Ian
You can't say this though, unless Access suports sub-selects?
code:

UPDATE table_name SET field_name = "1" & old_value WHERE field_name = old_value




Why would you want to do that tho?

code:
UPDATE table SET field=1100 WHERE field=100


Works fine for the given brief, assuming field datatype is numeric.




 
New Topic

New Poll

Corsa Sport » Message Board » General Chat » access update query help 23 database queries in 0.0073121 seconds