程序是这样的:
界面上有N个查询条件,分别对应数据库中不同的表(所有的表都用ID来关联 )
随便选择多少查询条件,点击查询按钮,即出面相应的报表
我现在是这样设计的:
sql="selet * from table1 a,table2 b table3 c......where a.id=b.id and a.id=c.id....." if 条件1!="" then
sql=sql&"and a.condition1=条件1"
end
if 条件2!="" then
sql=sql&"and b.condition1=条件2"
end
if 条件3!="" then
sql=sql&"and c.condition1=条件3"
end
...
类似这样 不过我感觉这样查询起来肯定会影响效率
因为一开始就把所有的表都放进SQL中查询了
请问有什么好点的解决方法?
界面上有N个查询条件,分别对应数据库中不同的表(所有的表都用ID来关联 )
随便选择多少查询条件,点击查询按钮,即出面相应的报表
我现在是这样设计的:
sql="selet * from table1 a,table2 b table3 c......where a.id=b.id and a.id=c.id....." if 条件1!="" then
sql=sql&"and a.condition1=条件1"
end
if 条件2!="" then
sql=sql&"and b.condition1=条件2"
end
if 条件3!="" then
sql=sql&"and c.condition1=条件3"
end
...
类似这样 不过我感觉这样查询起来肯定会影响效率
因为一开始就把所有的表都放进SQL中查询了
请问有什么好点的解决方法?
若果不是,就要每个条件根据查询内容写一个 from TBa,Tbb ,然后再拼装了。
另外.selet * 查询出来所有记录,影响效率呀,这里可以只查出你需要的字段.