There is a table mydocs with columns (id serial, docform int, content text) I make such a query

SELECT * FROM xpath_table('id','content','mydocs', '/tutorial/author|/tutorial/title', 'true') AS t(id int, author text, title text, docform int) 

prints id, author and title, in the docform column prints 0. How to display in the docform column the number related to its record in db.

    1 answer 1

     SELECT t.*, m.docform FROM mydocs m INNER JOIN LATERAL xpath_table('id','content','mydocs', '/tutorial/author|/tutorial/title', 'true') AS t(id int, author text, title text) ON m.id = t.id 

    This is how everything is derived, as I wanted even easier than I thought.