This would be your CTE with the anchor (topID saved): with cte as ( You can then save that into a temporary table, and use it as the basis of whatever you need to do - set the parent for any rows to the top level parent, set min createddate or max modified date, or delete the rows completely.ĭo it all set based rather than trying to loop through anything using a cursor. I'm sure this is not 100% of what you need, but it should give a good idea that you can use. It will also save the top level id as the anchor so that you can use it to roll the other ones up. I'm still not clear about the data and what you want to do, but this version of the CTE will find all rows that have no parent (parent is null), and then all its children. (ok there are occasions, but they really are for special purposes, not simple database updates). To answer your question about cursors, NO, NEVER! Any time you think about using a cursor you are almost certainly wrong. The CTE in your comment is close, but you are not saving the anchor point. I have dozens of them, so I need code that can crank through them all in like fashion. And in reality, Cycling is not my only set of duplicate folders. I would need to find descendants for both folders and consolidate them. Where id = 2757 -id for one of the Cycling folders I want to consolidate all descendants of both Cycling folders under one Cycling folder, and then remove the empty one, so I end up with just one Cycling folder but lose no content.Īs a first step, here is a query that will find all the descendants of one of the Cycling folders: In the example above, I don't want two Cycling folders. Many other folders and bookmarks omitted.As you can see in the schema, the moz_bookmarks table captures a hierarchical tree structure of bookmark folders and the bookmarks that belong to them, like so: You can easily access this database through a tool like the sqlite browser. If you're not familiar, Firefox stores its bookmarks on your hard drive in a file called places.sqlite. I have several duplicate folders in my bookmarks, because of a syncing process gone awry.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |