select user_name ,regist_Time,contact_name,company_phone,company_name from front_user where exists(select user_id,DAYOFMONTH(apply_time)as day from user_log   where 1=1
  #if($start_time &&!$start_time.equals("")) 
              and apply_time > '$start_time'
            #end
            #if($end_time &&!$end_time.equals("")) 
              and apply_time < '$end_time'
            #end
group by user_id,DAYOFMONTH(apply_time)) ss group by day
我是想把user_log表中的userid 全取出来,跟frontuser表中的userid进行对比 ,讲相同userid的用户信息输出来,但是执行后并没有执行子查询中的,请问是为什么

解决方案 »

  1.   

    建议在PHP中加入调试代码以确定实际的SQL语句是什么。
      

  2.   

    //你要把user_log表中user_id全部取出来,直接group by user_id就行了,为什么还要加上时间
    //或者distinct(user_id)
    //然后关联表查询,不知道是不是你想要的
    select a.user_name,a.regist_Time,a.contact_name,a.company_phone,a.company_name from front_user a,
    (select user_id from user_log where 1=1 and apply_time > '$start_time' and apply_time < '$end_time' group by user_id) ss
    where a.user_id = ss.user_id
      

  3.   

    select user_id from user_log where 1=1 and apply_time > '$start_time' and apply_time < '$end_time' group by user_id
    这个加上时间,可能没有数据的,两表关联可能没有结果。单独执行一次,有没有数据在看一下