大家好,我用同样的SQL语句。在jdbc进行查询得到1条记录,而在Mysql中直接查询,得到2条记录。百思不得其解阿,郁闷
如下:
String selectSql = "select ccd.timestamp, ccd.status, csd.start_time, cd.class_name from class_data cd, class_starttime_data csd, class_customer_data ccd where ccd.customer_id = (select cus_id from customer_data where email='"+ email+ "') and ccd.time_id = csd.time_id and csd.class_id = cd.class_id";class_customer_data表中,包含了customer_id、time_id

解决方案 »

  1.   

    自己先顶了。。
    这样看或许更直观一些:
    select ccd.timestamp, ccd.status, csd.start_time, cd.class_name from class_data cd, class_starttime_data csd, class_customer_data ccd where ccd.customer_id = 10003 and ccd.time_id = csd.time_id and csd.class_id = cd.class_id
      

  2.   

    你把select ccd.timestamp, ccd.status, csd.start_time, cd.class_name from class_data cd, class_starttime_data csd, class_customer_data ccd where ccd.customer_id = (select cus_id from customer_data where email='"+ email+ "') and ccd.time_id = csd.time_id and csd.class_id = cd.class_id
    这个语句输出来,直接执行一下,不太可能结果不一样
      

  3.   

    一般造成这种情况有可能是你的字符集问题,特别是有中文查询的情况下。http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
    MySQL 中文显示乱码