Hi,
I inserted a number of rows 3 hours ago and I don't want these rows from changing. How can I write sql statement that compare current time with the timstamp in the row and restrict users from changing it if abouve creteria is met.
Thanks
Hi,
I inserted a number of rows 3 hours ago and I don't want these rows from changing. How can I write sql statement that compare current time with the timstamp in the row and restrict users from changing it if abouve creteria is met.
Thanks
You can use a WHERE clause in all updates:
UPDATE yourtable
SET foo = bar
WHERE inserttime > NOW() - interval 3 hour
If you want to do it by using mysql, you will have to use the INTERVAL
statement which will allow you to "add" time to date functions... for instance:
UPDATE table
SET data = 'whatever'
WHERE NOW() - INTERVAL 3 HOUR < last_change
You can find more info and examples here: Date and Time Functions