Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kristoffer Eriksen 185 posts 465 karma points
    Jan 11, 2022 @ 13:12
    Kristoffer Eriksen
    0

    Get propertydata with SQL based on nodeID

    I've got some old SQL scripts which I used quite a while ago to get propertydata from the tables, based on a nodeid. But it's old and doesn't work anymore.

    I've searched the internet and forum, but can't fint a script that works, and can't get my head around the SQL structure.

    Does anybody have a SQL script that returns the latest version of propertydata based on a nodeid from umbracoNode table?

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Jan 12, 2022 @ 10:28
    Marc Goodson
    101

    Hi Kristoffer

    Insert usual warnings here about directly accessing content via SQL to the db, use the Umbraco Cache instead if presenting this data on a website etc etc

    that aside would something like this work for you?

      Select * from umbracoPropertyData upd INNER JOIN umbracoContentVersion ucv ON upd.versionId = ucv.Id WHERE ucv.[current] = 1 AND ucv.Nodeid = 1321
    

    Essentially because Umbraco stores tons of versions of the same page, the umbracoContentVersion table tracks which is the 'current' version based on a flag called 'current' - and it also includes the NodeId, so then you can just join this to the umbracoPropertyData table on the 'VersionId' and you'll get all the data for all the properties on that node for the 'current version'

    regards

    marc

  • Kristoffer Eriksen 185 posts 465 karma points
    Jan 12, 2022 @ 10:48
    Kristoffer Eriksen
    0

    Hey Marc

    Perfect. That solves my issue 100% :-)

    Thank you

    It's not an option to do it codewise, since it's an external agency that needs to be able to fetch specific data from the database directly.

    And yes, warnings have been made for the client :-)

    /Kristoffer

Please Sign in or register to post replies

Write your reply to:

Draft