示例
假设你有订单2009、订单2010、订单2011三个表,需要从这三个订单表中找出所有客户为“红阳事业”的订单:
Dim jb1 As New SQLJoinTableBuilder("查询表1","订单2009")
jb1.C
jb1.AddTable("订单","产品ID","产品","产品ID")
jb1.AddTable("订单", "客户ID","客户","客户ID")
jb1.AddCols("产品名称","客户名称","日期", "数量","单价")
jb1.AddExp("金额","数量 * 单价")
jb1.Filter = "客户名称 = '红阳事业'"
Dim jb2 As New SQLJoinTableBuilder("查询表1","订单2010")
jb2.C
jb2.AddTable("订单","产品ID","产品","产品ID")
jb2.AddTable("订单", "客户ID","客户","客户ID")
jb2.AddCols("产品名称","客户名称","日期", "数量","单价")
jb2.AddExp("金额","数量 * 单价")
jb2.Filter = "客户名称 = '红阳事业'"
Dim jb3 As New SQLJoinTableBuilder("查询表1","订单2011")
jb3.C
jb3.AddTable("订单","产品ID","产品","产品ID")
jb3.AddTable("订单", "客户ID","客户","客户ID")
jb3.AddCols("产品名称","客户名称","日期", "数量","单价")
jb3.AddExp("金额","数量 * 单价")
jb3.Filter = "客户名称 = '红阳事业'"
jb1.Union(jb2)
'组合jb2
jb1.Union(jb3) '组合jb3
jb1.Build()
MainTable = Tables("查询表1")