In this below example , instead of hardcoding Like expression “v.subject LIKE “%a%”” , how do I dynamically replace expression with query parameter like this
> FIELDNAME LIKE FIELDVALUE
Example :
CREATE QUERY print_a_posts() FOR GRAPH Social_Net {
posts = {Post.*};
a_posts = SELECT v FROM posts:v
WHERE v.subject LIKE “%a%”;
PRINT a_posts;
}
@sushmakundapur Here is a query I wrote that is taking “pName” (person name) as a parameter and then passes that param in the WHERE clause. Does this example help?
//SAMPLE QUERY
CREATE QUERY GetConnectedTo(STRING pName) FOR GRAPH Linkedin SYNTAX V2 {
TYPEDEF TUPLE <STRING TigerGraph_Employee, STRING Connected_To, STRING Position, STRING Company, STRING Email> PPL;
ListAccum<PPL> @@pplList;
STRING myParam;
myParam = "%" + pName + "%";
seed = {Person.*};
S1 = SELECT p FROM seed:s -(CONNECTED_TO:e)-Person:p
WHERE s.id LIKE myParam
ACCUM @@pplList += PPL(p.FullName, s.FullName, s.Position, s.Company, s.Email);
PRINT @@pplList;
}
1 Like