Hacker News new | past | comments | ask | show | jobs | submit login

I had some similar strategies:

1) Write the WHERE clause first

2) Run a SELECT on that WHERE clause

3) Edit the query to make it either update or delete as required

Similarly, I only ever perform recursive filesystem commands using find and xargs. I run the find first, then hit the up arrow and pipe it to whatever I want to do (I learned that one from a very patient sysadmin after I accidentally chmod'd -R / 664)




Been a few decades, but I was in a similar situation and came up with a similar approach. Run the select first and then swap in an update or delete.

If the query was somewhat involved to determine what to delete, I’d write the select query to just select row IDs of rows for deletion (assuming a simple primary key), then wrap that with a “delete from table where ID in (select ID from …complex query…)”.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: