brihol44
asked on
Update last 10 records?
Searched the web to find out how to update the last 10 rows of my table (MySQL) but I can't seem to find anything. Is there such a way? I need to be able to update the last 10 rows dynamically so I won't know any specific ID's to specify the update.
Thanks,
Thanks,
So something like:
UPDATE Set field = blah ORDER BY id_field DESC LIMIT 10
UPDATE Set field = blah ORDER BY id_field DESC LIMIT 10
ASKER
hmm.....I'm getting an error with my update statement.
Incorrect usage of UPDATE and ORDER BY
Incorrect usage of UPDATE and ORDER BY
UPDATE stats_daily s
INNER JOIN stats_daily_temp st
ON s.date = st.date
SET s.page_views = st.page_views,
s.visits = st.visits,
s.hits = st.hits,
s.bandwidth = st.bandwidth
WHERE s.date = st.date
ORDER BY daily_id DESC LIMIT 10
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
brihol: Did you get this to work?
ASKER
Yes, thanks! I was on vacation for some time and I'm back getting into this part of the project.
Thanks,
B
Thanks,
B
so, just use the proper ORDER BY and add the LIMIT 0,10, so it should be fine.