Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Entwicklung
    4. SQL-Abfrage mit Variable

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    SQL-Abfrage mit Variable

    This topic has been deleted. Only users with topic management privileges can see it.
    • ice987
      ice987 last edited by ice987

      Hallo zusammen,

      Könnte mir jemand helfen bezüglich einer SQL Abfrage?

      Ich habe eine Logging-Funktion erstellt, mit welcher ich die Zustände mehrerer Geräte wie folge auslesen kann:

      sendTo('sql.0', 'query', 'SELECT id, ts, val, _from FROM iobroker.ts_bool WHERE iobroker.ts_bool.id IN(SELECT id FROM iobroker.datapoints WHERE iobroker.datapoints.name IN ('hm-rpc.0.123.3.STATE', 'hm-rpc.0.456.3.STATE')) ORDER BY ts DESC limit 100', function (sqlResult) {...}
      

      Nun möchte ich die beiden Geräte „('hm-rpc.0.123.3.STATE', 'hm-rpc.0.456.3.STATE')“ als Variable deklarieren, damit die Aktualisierung bei neuen Geräte einfacher ist:

      let devices = ('hm-rpc.0.123.3.STATE', 'hm-rpc.0.456.3.STATE');
      
      sendTo('sql.0', 'query', 'SELECT id, ts, val, _from FROM iobroker.ts_bool WHERE iobroker.ts_bool.id IN(SELECT id FROM iobroker.datapoints WHERE iobroker.datapoints.name IN devices) ORDER BY ts DESC limit 100', function (sqlResult) {...}
      

      wie muss dies umgesetzt werden, damit dies auch funktioniert?

      Vielen Dank für eure Hilfe,

      ice987 1 Reply Last reply Reply Quote 0
      • ice987
        ice987 @ice987 last edited by

        @ice987
        Push

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        411
        Online

        31.9k
        Users

        80.2k
        Topics

        1.3m
        Posts

        sql
        1
        2
        456
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo