扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:佚名 来源:博客园 2007年11月11日
关键字:
SelectQueryBuilder query = new SelectQueryBuilder(); query.SelectColumns("count(*) AS Count", "ShipCity"); query.SelectFromTable("Orders"); query.GroupBy("ShipCity"); query.AddHaving("ShipCity", Comparison.NotEquals, "Amsterdam"); query.AddOrderBy("count(*)", Sorting.Descending); |
SELECT count(*) AS Count, ShipCity FROM Orders GROUP BY ShipCity HAVING (ShipCity <> 'Amsterdam') ORDER BY count(*) DESC |
SelectQueryBuilder query = new SelectQueryBuilder(); query.SelectFromTable("Orders"); // Add 'Criteria' column to level 1 query.AddWhere("CustomerID", Comparison.Equals,"VINET", 1); query.AddWhere("OrderDate", Comparison.LessThan,new DateTime(2005,1,1), 1); // Add first 'Or...' column to level 2 query.AddWhere("CustomerID", Comparison.Equals, "TOMSP", 2); query.AddWhere("OrderDate", Comparison.LessThan,new DateTime(2004,6,30), 2); // Add second 'Or...' column to level 3 query.AddWhere("CustomerID", Comparison.Equals,"TOMSP", 3); query.AddWhere("OrderDate", Comparison.GreaterThan,new DateTime(2006,1,1), 3); |
SelectQueryBuilder query = new SelectQueryBuilder(); query.SelectFromTable("Orders"); // Add 'Criteria' column to level 1 query.AddWhere("CustomerID", Comparison.Equals, "VINET", 1); query.AddWhere("OrderDate", Comparison.LessThan, new DateTime(2005,1,1), 1); // Add 'Or...' column to level 2 query.AddWhere("CustomerID", Comparison.Equals, "TOMSP", 2); // Add the date selection clause WhereClause clause =query.AddWhere("OrderDate", Comparison.LessThan, new DateTime(2004,6,30), 2); // Add a nested clause to the captured clause clause.AddClause(LogicOperator.Or, Comparison.GreaterThan, new DateTime(2006,1,1)); |
SELECT Orders.* FROM Orders WHERE ( (CustomerID = 'VINET') AND (OrderDate < '2005/01/01 12:00:00') ) OR ( (CustomerID = 'TOMSP') AND (OrderDate < '2004/06/30 12:00:00' OR OrderDate > '2006/01/01 12:00:00') ) |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。