I'm expecting an ArcObjects code which is equivalent to SQL left join.
For example: I have the below SQL code, it's simple join to fetch the records from the both tables based on the ChecklistId
value.
SELECT T1.ChecklistId, T1.ChecklistName,
T2.Latitude, T2.Longitude
FROM [dbo].[TableOne] T1
INNER JOIN [dbo].[TableTwo] T2 ON T2.ChecklistId = T1.ChecklistId
WHERE T1.ChecklistId = @ChecklistId
I converted the above SQL query into the ArcObjects.
IQueryDef queryDef = featureWorkspace.CreateQueryDef();
queryDef.Tables = "TableOne, TableTwo";
queryDef.SubFields = "TableOne.ChecklistId, TableOne.ChecklistName, TableTwo.Latitude, TableTwo.Longitude";
queryDef.WhereClause = "TableOne.ChecklistId = '" + checklistId + "' AND TableOne.ChecklistId = TableTwo.ChecklistId";
ICursor cursor = queryDef.Evaluate();
IRow row = null;
while ((row = cursor.NextRow()) != null)
{
// ... get and set the values to the objects
}
I want to fetch the records even the T1.ChecklistOwner
column having null
values. In simple words we can say as SQL LEFT JOIN
as follows:
SELECT T1.ChecklistId, T1.ChecklistName,
T2.Latitude, T2.Longitude,
T3.FullName
FROM [dbo].[TableOne] T1
INNER JOIN [dbo].[TableTwo] T2 ON T2.ChecklistId = T1.ChecklistId
LEFT JOIN [dbo].[TableThree] T3 ON T3.UserAlias = T1.ChecklistOwner
WHERE T1.ChecklistId = @ChecklistId
How can I convert the above SQL query into ArcObjects?