Trouble with nested select query
Posted: Sun 12 Jan 2014 22:42
This works perfectly outside of DevArt in a MySQL query browser:
I am trying to get the most recent sensor readings and display them neatly formatted. Each sensor has different numeric precision formatting.
v8.2.5 chokes on the column named "digits" if I try to put it into a TMyQuery component. As you can see, there is no column named digits in my main select. Digits is a column name in the sensors table that holds the amount of numeric precision for a given sensor.
Ok, so I quote the "digits" field in the query to try to fool your parser. Now it always returns 0 for the format precision.
Any ideas or workarounds?
Thanks!
Kevin
Code: Select all
select s.name, format(sv.value,(select digits from sensors where id=s.id)) as value
from sensors s, sensorvalues sv, packets p
where (select id from packets where packettype=2 order by timestamp desc limit 1) = p.id and sv.id=p.id and sv.sid=s.idv8.2.5 chokes on the column named "digits" if I try to put it into a TMyQuery component. As you can see, there is no column named digits in my main select. Digits is a column name in the sensors table that holds the amount of numeric precision for a given sensor.
Ok, so I quote the "digits" field in the query to try to fool your parser. Now it always returns 0 for the format precision.
Any ideas or workarounds?
Thanks!
Kevin