LiveCloud Forums
Query Builder and Code Snippet - Printable Version

+- LiveCloud Forums (https://forums.livecloud.io)
+-- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=1)
+--- Forum: Code Samples (https://forums.livecloud.io/forumdisplay.php?fid=7)
+--- Thread: Query Builder and Code Snippet (/showthread.php?tid=366)



Query Builder and Code Snippet - efrain.c - 03-02-2020

Hi everyone,

We've received a few questions regarding query. This video shows how you can use the query builder and code snippet to build a query and generate the code needed to perform the query: https://youtu.be/6g2pFEvdLcc

You can then take the code from the code snippet and use the output of the query to generate a list of names as follows:

Code:
local tInputA, tOutputA, tList

put cdb_query("trip","=","trip1","testTable","cloud","recordData") into tOutputA

//EACH KEY OF tOutputA CONTAINS THE recordID OF A RECORD THAT MATCHES THE QUERY CRITERIA
//WE REPEAT THROUGH EACH KEY TO ACCESS THE DATA IN EACH RECORD
repeat for each key xRecordID in tOutputA
    //GRAB THE NAME OF THE PERSON IN THIS RECORD TO CREATE A LIST
    put tOutputA[xRecordID]["person"] & lf after tList
end repeat

//DELETE TRAILING LF
delete char -1 of tList

We hope examples like this with short videos will be helpful. Let us know if there's a topic you would like us to cover.