Topic: Unions |
Posted On: 12/17/2008 5:46 PM
Posted By: Thomas W
|
Is there a way to do unions with QO? Looking for something that could produce results similar to this query:
SELECT MyVarCharColumn FROM [TableA] WHERE MyVarCharColumn LIKE @criteria
UNION
SELECT MyOtherVarCharColumn FROM [TableB] WHERE MyOtherVarCharColumn LIKE @criteria
ORDER BY 1
Thanks,
Thomas
Hi Thomas,
UNIONS are not directly handled by QO but you can still very easily do this. I have the sample code below:
| using (Customers customer = new Customers()) | | { | | customer.ObjectMode = Akal.QuickObjects.ObjectBase.ObjectModes.Search; | | customer.FirstName.StartsWith("F"); | | customer.SetVisibleFields(true, customer.FirstName); | | | | Products product = new Products(customer); // share the connection | | product.ObjectMode = Akal.QuickObjects.ObjectBase.ObjectModes.Search; | | product.ProductName.Contains("Q"); | | product.SetVisibleFields(true, product.ProductName); | | | | ArrayList ar = new ArrayList(); | | | | string sql = customer.GetSelectSQL(ref ar); | | sql = sql + " UNION " + product.GetSelectSQL(ref ar); | | sql = sql + " ORDER BY 1"; | | DataSet ds = customer.RunSQLReturnDataset(sql, ar); | | } | | |
Hope this helps.
Thanks, Ish
| 12/17/2008 11:16:11 PM Ish Singh
|