[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
SqlUpdate
For example:
Value should be in quotes if it is a non-numerical data type, and not in quotes if it isn't. If you only want to change X number of records, use the LIMIT clause for that. This can be a good security mechanism if you know the condition should only ever change 1 item - even if someone does an exploit that would potentially update all items or other items, damage can be limited.
Note that the value can be a function of the existing value. This is useful for applying changes where the data changes regularly and could change between the data being obtained and the proccessed data being updated (e.g. in a stock control system).
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
SqlUpdate
(SQL) UPDATE
Updates existing records in a table in a database matching the required condition.UPDATE tablename SET Field1 = 'Value1', Field2 = 'Value2', ... WHERE Condition LIMIT MaxRecordsToChange
For example:
-- A person that changed her last name by marriage UPDATE Persons SET LastName = 'Flintstone ' WHERE FirstName = 'Wilma' AND LastName = 'Dinobush'
Value should be in quotes if it is a non-numerical data type, and not in quotes if it isn't. If you only want to change X number of records, use the LIMIT clause for that. This can be a good security mechanism if you know the condition should only ever change 1 item - even if someone does an exploit that would potentially update all items or other items, damage can be limited.
Note that the value can be a function of the existing value. This is useful for applying changes where the data changes regularly and could change between the data being obtained and the proccessed data being updated (e.g. in a stock control system).
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
