Skip to content
Advertisement

Tag: common-table-expression

MySQL – Recursively list all parents and ancestors of all items in table

I have a table with a parent/child hierarchy that supports multiple (theoretically infinite) levels of nesting: I am trying to build a query that produces a concatenated list of every item’s parent items up until the highest parent in the tree: Based on a number of other answers here I have constructed the following MySQL query: See Fiddle here: http://sqlfiddle.com/#!9/48d276f/902/0

SQL append data to table using dense_rank()

I’ve been trying to piece together bits of code that I’ve googled but haven’t had any luck. I’m trying to add a new column to an existing table. I can view the column using the below code from a select query: I basically want to append the results from this select query to my original table. I’ve tried using a

Advertisement