我的sql语句都很长,在一行看起来不方便

解决方案 »

  1.   

    例子:Frmnongcunfapiaobaishui.adoquery2.SQL.Add('select distinct a.coulometer_id,a.coulometer_type, '
        + 'a.meter_multiple,b.last_total_value,b.this_total_value,  '
        + 'isnull(b.additional_power,0) additional_power,  '
        + 'isnull(b.barter_power,0) barter_power, '
        + 'isnull(b.mid_carrier_lose,0) bxs,  '
        + 'isnull(b.mid_copy_value,0) sum_mid_power  '
        + 'from customer_meter a,customer_used_power b,power_fee_sheet c  '
        + 'where a.coulometer_id=b.coulometer_id and '
        + 'a.coulometer_id=c.coulometer_id and rtrim(c.integ_price_id)<>' + '''' + ''''
        + ' and c.copy_yearmonth=b.copy_yearmonth and b.copy_yearmonth='
        + '''' + Frmnongcunfapiaobaishui.tmonth + '''' + ' and a.customer_id= '
        + '''' + Frmnongcunfapiaobaishui.CUSTOMERID + '''');
      

  2.   

    #13#10以前用过,反正要用到这个东西,
    象事物处理的时候SQL要在GO的地方换行。
      

  3.   

    adoquery1.sql.add('select *');
    adoquery1.sql.append('from table');
      

  4.   

    就像: mrfanghansheng(***木鱼***) 
    就OK啦直接用“+”连接
      

  5.   

    SQLS:='select ' + end_area +',"' +
                  '甲级' + '" as lb1,sum(iif(xzzdj="' + '甲级' +'",1,0)) as n1,"' +
                  '乙级' + '" as lb2,sum(iif(xzzdj="' + '乙级' + '",1,0)) as n2,"' +
                  '丙级' + '" as lb3,sum(iif(xzzdj="' + '丙级' + '",1,0)) as n3' +
                  ' from '+ PreName+'zjzxdwjbqk ' +
                  ' where len(' + end_area + ')>2' +
                  ' and ' + end_area + ' in (' +
                  ' select ' + end_area + ' from '+ PreName+'zjzxdwjbqk ' ;
    adoquery1.sql.clear;
    adoquery1.sql.add(sql);
      

  6.   

    strSQL := ' select keyfield = a.vc_user + cast(a.i_date as char(8)) + cast(a.i_time as char(6))'
                + '        , a.i_date, a.i_time, a.vc_user, b.vc_user_name, a.i_busin_flag, a.vc_computer_name'
                + '        , a.vc_login_ip, a.i_busin_flag, vc_busin_caption = '' '', a.tx_detail'
                + ' from runbase..userlogs a, runbase..users b where ' + sWheres;
        CommandText := strSQL;
        open;