代码:
ls_select:='select count( survived ) as ll_att_value_count from data_titanic where sex="male" group by survived';
Query1.Close;
Query1.sql.clear;
Query1.sql.add(ls_select);
Query1.open;
Query1.first;
每次运行到Query1.open;时报错:列名'male'无效。
请各位大侠帮忙!

解决方案 »

  1.   

    哈哈,你呀,没调试,在delphi 
    where sex='+''''+'male'+''''+'group by survived';
      

  2.   

    ls_select:='select count( survived ) as ll_att_value_count from data_titanic where sex=''male'' group by survived';
      

  3.   

    你sex类型是varchar吗?
    一般是你的数据表字段类型与你的SEX不一致哈
      

  4.   

    前面的昭旧,是因为sql中的要单引号,而不用“这种符号,在DELPHI中要的是''''外边的两个引号代替字符串,里边的相当于C中的\',呵呵
      

  5.   

    ls_select:='select count( survived ) as ll_att_value_count from data_titanic where sex='+char(39)+'male'+char(39)+' group by survived';
      

  6.   

    where sex='+''''+'male'+''''+'group by survived';你把'male'改成一个字符串变量就可以根据用户的要求来查询了