请教多条件查询如何排序
sql="select * from table Where 1=1"
if a1<> "" then
sql =sql & " and a1="x""
end If
if a2<> "" then
sql =sql & " and a2="xx""
end If
if a3<> "" then
sql =sql & " and a3 ="xxx""
end If
这样写多条件查询确实省事,但是缺点是不能排序了,无法在后面加order by xx了,因为where 1=1后面必须直接接and语句,假如直接接order by的话后面就不能接条件查询的and语句,那么这种情况下怎么排序呢?请教高人了。