This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SQL Inner join
#3
Thanks so much. This syntax document was extremely helpful.
Posting the resulting SELECT statement for inspiration

Example: Read all entries from the object log occurring after a certain logtime and only for all objects having a certain tag

This did the trick:

*********** START CODE ****************

query = [[
SELECT objectlog.src, objectlog.address, objectlog.datahex, objectlog.logtime, objectlog.eventtype
FROM objectlog
JOIN objects ON objectlog.address=objects.address
JOIN objecttags ON objects.address=objecttags.object
WHERE objecttags.tag=? AND objectlog.logtime>?
ORDER BY objectlog.id ASC
]]

-- Remember to have initiated the sCurrTag and iLastTime variables with the specific values
for _, row in ipairs(db:getall(query,sCurrTag, iLastTime)) do
...do stuff with row....
end

*********** END CODE ****************
Reply


Messages In This Thread
SQL Inner join - by mjaanes - 03.04.2020, 18:48
RE: SQL Inner join - by admin - 03.04.2020, 19:41
RE: SQL Inner join - by mjaanes - 04.04.2020, 09:26

Forum Jump: