0

I'm expecting an ArcObjects code which is equivalent to SQL Query or way to do it or even if it is achievable ?

For example: I have the below SQL code, it's simple join to fetch the records from the multiple tables based on the some matching value.

Select * FROM T1  
JOIN T2 ON t1.T1_ID = t2.T2_ID 
JOIN T3 ON t3.GLOBALID = t2.T2_GUID 
JOIN T4 trf ON t4.GLOBALID = t2.T3_FUID
LEFT JOIN (
    SELECT P_COL, Q_COL, R_COL, S_COL from T5
    UNION
    SELECT P_COL, Q_COL, R_COL, S_COL from T6
    Union
    SELECT P_COL, NULL AS Q_COL, R_COL, S_COL from T7
) T8 ON T8.GLOBALID = T4.T4_GUID
where T1.matchingValue = "ABC";

i have used following function to create QueryDef

public static IQueryDef CreateQueryDef(IFeatureWorkspace featureWorkspace, string tables, string subFields, string whereClause)
{
   // Create the query definition.
   var queryDef = featureWorkspace.CreateQueryDef();

   // Provide a list of table(s) to join.
   queryDef.Tables = tables;

   // Declare the subfields to retrieve.
   queryDef.SubFields = subFields; // must be qualified if multiple tables !!

   // Assign a where clause to filter the results.
   queryDef.WhereClause = whereClause;

   return queryDef;
}

it is working fine for multiple table

 var queryDef = CreateQueryDef(featureWorkspace,
      tables:"T1,T2,T3,T4", 
      subFields: "T2.G_ID, T1.T1ID, T2.N_ID, T2.M_ID",
      whereClause: "t1.T1_ID = t2.T2_ID and t3.GLOBALID = t2.T2_GUID and t4.GLOBALID = t2.T3_FUID and T1.matchingValue = "ABC"");

I am not able to figure out how to Union t5,t6,t7 and create a result set for this in same query.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.